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

Imperatively declared element's custom fired event does not bubble up. #1212

Closed
Werner-Swart-83 opened this issue Feb 23, 2015 · 3 comments
Closed

Comments

@Werner-Swart-83
Copy link

I have JSBin example (http://jsbin.com/wahapu/3/edit?html,console,output) where there are 3 custom elements. When they are declared declaratively I can catch the event as expected from the parent elements, but when I declare an element imperatively and force the event to fire the parent elements do not pick it up.

Although this example is useless it self, I found this problem with one of my projects where I had a "sign-out" event fired from an custom ajax element when the token expired. I like to use the ajax element imperatively rather then declaratively since nothing is rendered on the screen and I can read those elements that render easier in the template section.

@ghost
Copy link

ghost commented Feb 23, 2015

You need to add the created element to the DOM for its events to bubble. Just calling new elementThree() doesn't automatically append the element to the DOM. In your jsbin sample, add the line document.body.appendChild(target); right after the line var target = new elementThree();

Just a thought: if you're creating and using Polymer elements that in anyway interact with the UI, like for example firing custom events meant to bubble up the DOM that result in the UI changing, I would highly recommend using them declaratively. Otherwise, don't create a custom Polymer element, rather just use a function or class. One of the greatest things about Polymer is that anything that effects or is effected by UI can be declared with HTML.

@Werner-Swart-83
Copy link
Author

Ah, thank you, that worked.

@ghost
Copy link

ghost commented Feb 23, 2015

No problem :). You might want to close this issue.

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

1 participant