-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add constructor for BeforeUnloadEvent #2574
Comments
(See whatwg/dom#445) |
Fixes whatwg#2574. This is consistent with all other event types defined in the spec, and the way we do things today in general.
So this event was added in 246c3b4 which includes a note (still in the spec today) + <p class="note">There are no <code>BeforeUnloadEvent</code>-specific
+ initialization methods.</p> email: https://lists.w3.org/Archives/Public/public-whatwg-archive/2008Dec/0146.html irc ramblings: https://krijnhoetmer.nl/irc-logs/whatwg/20081212#l-99 So... at that time event constructors didn't exist. But at least it seems intentional to not include If we add a constructor, you would be able to fire a |
The constructor needn't allow you to initialize anything. It can take a plain EventInit dict, so it just lets you create it with no flags (beyond bubbles and cancelable, which you can set now with initEvent). You can already fire a BeforeUnloadEvent in a beforeunload handler using createEvent(), in Chrome and Firefox. This is consistent with the way the rest of the platform works. Browsers already don't have to display the dialogs if they don't want to, so I think this can be left to a QoI issue, unless you have a specific concern that you think should be in the spec. |
Oh I mistakenly thought "beforeunloadevent" was not in https://dom.spec.whatwg.org/#dom-document-createevent . Then I agree there are no new abilities. Test for my scenario with It seems the browsers I have don't show more than one dialog. Looking at the spec, it's clear that the prompt can only appear because of the UA-generated event. |
Fixes whatwg#2574. This is consistent with the way events behave these days in the platform.
We normally allow authors to instantiate their own events (although I don't know why). These days we do this with constructors, so BeforeUnloadEvent should have a constructor. AFAICT, every other event type defined in the spec already has one.
The text was updated successfully, but these errors were encountered: