Skip to content
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

"Assertion Failed" unwrapping event #636

Closed
keithamus opened this issue Jul 15, 2014 · 2 comments
Closed

"Assertion Failed" unwrapping event #636

keithamus opened this issue Jul 15, 2014 · 2 comments

Comments

@keithamus
Copy link

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:

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.

@arv
Copy link
Contributor

arv commented Jul 15, 2014

The issue is with document.body which cannot be wrapped due to this Safari bug: https://bugs.webkit.org/show_bug.cgi?id=122018

If you change it to document.querySelector('body').dispatchEvent it works: http://jsbin.com/gipunuhu/1/

Also, you might want to use new MouseEvent in the future to skip that ugly initMouseEvent crap: http://jsbin.com/gipunuhu/3/edit

@arv arv closed this as completed Jul 15, 2014
@keithamus
Copy link
Author

Sorry - the document.body element is actually a red herring in this case. The element I was dispatching the event on was hanging off of my custom elements $ property - but I can't seem to reproduce now. I'll re-open if I can

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants