Closed Bug 882165 Opened 11 years ago Closed 2 years ago

document.createEvent('FocusEvent') is throwing

Categories

(Core :: DOM: Events, defect, P5)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1388069

People

(Reporter: erik, Unassigned)

Details

document.createEvent('FocusEvent')

is throwing

[11:33:48.888] [Exception... "Operation is not supported"  code: "9" nsresult: "0x80530009 (NotSupportedError)"  location: "debugger eval code Line: 1"]
The partial implementation in bug 855741 broke https://github.com/Polymer/ShadowDOM
Assignee: nobody → ayang
OS: Linux → All
Hardware: x86_64 → All
Version: unspecified → Trunk
Hmm, I'd say the spec (D3E) should just change.
Isn't listed here:

http://dom.spec.whatwg.org/#dom-document-createevent

Is there a particular reason you think this should be implemented?
> Is there a particular reason you think this should be implemented?(In reply to :Ms2ger from comment #3)
> Is there a particular reason you think this should be implemented?

Works in WebKit/Blink?

I'm fine fixing my code though.
If we implement that, we should update the spec instead of depending on the hidden secret of WebKit/Blink.
IE allows document.createEvent('FocusEvent') but not new FocusEvent(...).

I would not call this a hidden secret. This was the way events where create and initiated (IE even has an initFocusEvent on the FocusEvent interface.)

Still, I think not implementing this might be better since it would encourage people to start using new FocusEvent which is clearly a better API.

Feel free to close as you see fit.
This happend not only for FocusEvent. Of course constructor is modern/better but now for document.createEvent() whe have this for basic interface:

Event, CustomEvent, UIEvent, MouseEvent, KeyboardEvent, CompositionEvent << work in all browser
FocusEvent, WheelEvent << work only in Chrome and IE
*Firefox and IE are case-insensitive but Chrome is case-sensitive.

So, Firefox miss only two interface from D3E, but still support KeyboardEvent, CompositionEvent (because at now they can not be called as a constructor).

D3E allows pass any names which are supported + some legacy name:
https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-DocumentEvent-createEvent

DOM4 allows the same legacy name and including only Event, CustomEvent, UIEvent, MouseEvent:
http://dom.spec.whatwg.org/#dom-document-createevent

All this make little confusing, specifications and browser are different in the area. Not all constructors are supported, even in Firefox, like new CompositionEvent() and new KeyboardEvent(). So now we still must use old document.createEvent() for some interface and abandoning them in the future can cause next problems. Maybe all this basic interface (from D3E) should be supported?
Small correct:
Chrome support document.createEvent("FocusEvent") but missing FocusEvent.initFocusEvent, so create event in this way doesn't make any sense (we can not initialize them).

The only plus to maintain init*Event method is possibility to reinicialize event, after finish its propagation path. We can change properites of event and dispatch it again. With constructor it's impossible (we must create new event). But I don't know if this behaviour is often useful (if any).
Assignee: ayang → nobody

Bulk-downgrade of unassigned, >=3 years untouched DOM/Storage bug's priority.

If you have reason to believe this is wrong, please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5

document.createEvent('FocusEvent') no longer throws.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
Duplicate of bug: 1388069
Resolution: WORKSFORME → DUPLICATE
You need to log in before you can comment on or make changes to this bug.