Description
Abstract
I seem unable to simply instantiate an Event and dispatch it. Firefox throws an "Assertion Failed" error. This works fine in Chrome however (where I assume the ShadowDOM Polyfill is an effective no-op as Chrome already implements Shadow DOM).
Detail
I have polymer loaded, but I'm trying to manually instantiate a MouseEvent, and dispatch it to a regular DOM element - not involving Polymer. Because dispatchEvent and all of the event constructors have been overwritten, it goes through Polymer code.
I have a reduced test case available here.
document.createEvent('MouseEvent') creates me a GenericEvent from the ShadowDOM (see ShadowDOM events.js:L508-533. The problem seems to be dispatching the event, where an assertion fails in unwrap. The stack looks something like:
throw new Error('Assertion failed');
(ShadowDOM wrapper.js:L33)- (from
assert()
) (ShadowDOM wrapper.js:L31-34)
- (from
isWrapper(event)
(ShadowDOM wrapper.js:L326)- (from
isWrapper()
) (ShadowDOM wrapper.js:L279-287) - (from
unwrap()
) (ShadowDOM wrapper.js:L323-328)
- (from
unwrap(event)
(ShadowDOM:L763)- (from
dispatchEvent(event)
) (ShadowDOM:L752-788).
- (from
The conclusion of this is that the GenericEvent function does not return instances of the wrappers.* constructors - although I am sure the issue is more nuanced.