Bug 188083
| Summary: | The instanceof operator does not work as expected for classes that extend CustomEvent or Event | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Eugene Kashida <ekashida> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED CONFIGURATION CHANGED | ||
| Severity: | Normal | CC: | ashvayka, cdumez, keith_miller, rniwa, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Mac | ||
| OS: | Unspecified | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=174313 | ||
Eugene Kashida
Overview:
class FooEvent extends CustomEvent {
constructor() {
super('foo');
}
};
var foo = new FooEvent();
console.log('This evaluates to "false" which is unexpected', foo instanceof FooEvent);
console.log('This evaluates to "true" which is expected', foo instanceof CustomEvent);
console.log('This evaluates to "true" which is expected', foo instanceof Event);
Expected Results:
The instanceof operator, when given an instance of FooEvent which extends CustomEvent, and the FooEvent constructor, should evaluate to "true".
Build Date & Hardware:
Release 61 (Safari 12.0, WebKit 13606.1.25.1)
Mac OS 10.13.6
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Ryosuke Niwa
I don't think class inheritance ever worked with Event's.
Eugene Kashida
It seems to be working as expected in Firefox and Chrome, and Edge has the following open issue:
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11923584/
Alexey Shvayka
(In reply to Eugene Kashida from comment #0)
> Expected Results:
>
> The instanceof operator, when given an instance of FooEvent which extends
> CustomEvent, and the FooEvent constructor, should evaluate to "true".
As of https://trac.webkit.org/changeset/256716, extending CustomEvent (as well as other DOM constructors) works as expected.
Radar WebKit Bug Importer
<rdar://problem/60743143>