Listening to a polymer attached event from outside that element -
in team trying write unit tests polymer custom elements. of our custom elements uses polymer's template binding feature have lots of code written under attached callback of custom element. when writing unit tests these elements can listen polymer-ready event need run our test suite after polymer-attached event binding has been complete.
right have done dirty checking element want check our test suite runs after complete template gets bounded.
i have seen post polymer exposes way listen ready event need way listen polymer's attached event outside polymer.
i think there few ways solve this.
- fire own custom event new
domreadycallback or monkey patchdomreadyin test harness calls callback element has defined, , dispatches custom event. - create mutation observer monitors parent element , can detect when new child has been inserted dom. i've made an example jsbin. note: mutation observer not work if element in dom. you'll need setup mutation observer first, add element page.
Comments
Post a Comment