Skip to content

"Assertion Failed" unwrapping event #636

Description

@keithamus

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.

Activity

  1. arv commented on Jul 15, 2014

    @arv
    Contributor

    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

  2. keithamus commented on Jul 15, 2014

    @keithamus
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions