-
Notifications
You must be signed in to change notification settings - Fork 308
Clarify behaviour of constructor in class Foo extends Event {}
#598
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
Comments
@domenic why is it again that we can just say " |
In Safari/Edge, it seems like class Event {
constructor() {
return Object.create(Event.prototype);
}
} Which you could argue is correct according to:
Although this is in a non-normative section. There aren't any normative steps for the event constructor. |
There are: https://dom.spec.whatwg.org/#constructing-events. They seem to cover the inheritance aspect actually. But we don't cover it for |
Ah, sorry. The constructor in the IDL links to the non-normative section. |
This is all defined in the IDL for [Constructor]. I can find it when back at a computer. |
https://heycam.github.io/webidl/#interface-object I guess, though I can't quite figure out where that deals with subclassing. |
It links nowhere in the IDL. The non-normative version links to the IDL though. That seems worth fixing. |
Hmm yeah I guess that's broken right now. @tobie and I talked about how to fix it a month or so ago. (Roughly, instead of converting R to O, O should be created by ObjectCreate(new.target.prototype), and save R as an internal [[IDLValue]] slot.) |
I filed #604 on [Constructor] not linking and whatwg/webidl#533 on [Constructor] not taking into account subclasses properly. Bugs were already filed. Interested in adding a web-platform-tests test? |
I can write some tests for |
Just for Event for now I think (pretty sure EventTarget is covered). Thanks! |
Turns out it's already covered http://w3c-test.org/dom/events/Event-subclasses-constructors.html |
\o/ |
Uh oh!
There was an error while loading. Please reload this page.
Chrome & Firefox say
Foo
, Edge & Safari sayEvent
.Chrome & Firefox say
hello
, Edge & Safari throw (undefined is not a function).The Chrome/Firefox behaviour is preferable, as it allows you to create custom event objects.
The text was updated successfully, but these errors were encountered: