-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: alert, confirm, prompt, and their async counterpart #4257
Comments
Sounds reasonable... |
My fear is that they could easily become vectors for a DOS attacks, so we would want to put them behind permission flags. They have been abused so much in browsers it lead to the notifications API. I would much rather see us implement the notifications API and move the permissions to the global namespace. |
What type of attacker you are talking about? I wouldn't allow my server to execute arbitrary code from the user so a malicious user shouldn't be able to call
I don't think this is necessary either. These window methods only block when stdin is interactive (waiting for user to type in input). If stdin is not interactive (such as pipeline), then these methods shouldn't block execution.
I fail to see any negative in this. It is true that
On Electron and deno_webview, this is a must-have. But Deno is CLI only, it does not aim to provide full-fledged web APIs. |
But someone calling
Exactly. A good reason not to implement these. The reason we implement any of the APIs for the web is to increase code portability. My opinion still is that if you are authoring isomoprhic code, you wouldn't be using these APIs in the browser, so why use them in the CLI? If you don't like my opinion about them being "bad" APIs, take a look at the desire from those involved in the standards bodies who want to remove them from the web... |
We don't want to allow unknown code to read from the our filesystem because we concern about our own security, not security of our users. I will try my best to guess your concern: You are worrying that a library that does not use Anyway, if reading from stdin requires permission, then
I don't know how serious should I take a Twitter post. If
Currently, browser and Deno do not share any API for basic I/O: stdio does not exist in the browser and HTML does not exist in Deno. Furthermore, when new developers first learn JavaScript, there's a good chance that they will learn and use |
I think this kind of feature, especially |
As you may have heard, there is widespread debate about the deprecation of these methods, which have clear deficiencies - their deprecation was proposed in 2017 and hasn't happened, but there's been pressure from the Chrome team and others to get it moving, and it's sparking a lot of debate online. As many have pointed out, despite their problems, these methods actually fill a need - I've seen many making the argument that these should not be deprecated before there's an alternative. For example, these are useful for beginners and for prototyping. This doesn't need to be something big and fancy, just an async (Promise) version of those 3 basic interactions. The biggest issue is probably naming. How do you name these or where do you put them? Perhaps someone from the Deno team could step in with a proposal? 🙂 |
@mindplay-dk Async or not, using these methods to interact with users is bad UX. A professional web developer should at least make a |
Well, of course. I don't think anyone claims it's good UX to use these methods. The web had form elements long before it even had JavaScript, so I don't think this was never intended for primary UI. But these are useful features for beginners, for quick prototyping, and sometimes for personal/one-off scripts. |
Rationale
The browser already provides
window.alert
,window.confirm
,window.prompt
. I think it would be nice if Deno supports them too.Implementation
window.alert
simply prints text to stdout and wait for user to press any key.window.confirm
asks a yes/no question, waits to for user to respond either "y", "yes", "n", or "no".window.prompt
asks user to enter a string.Deno
namespace.The text was updated successfully, but these errors were encountered: