Child nodes inside conditional template not available at attached()

19 views
Skip to first unread message

Leandro Cruz

unread,
Jul 18, 2014, 2:10:15 PM7/18/14
to webcom...@googlegroups.com
I have a custom element that defines a template like this:
<template>
<template if="{{ someValue }}">
<div id="my"></div>
</template>
</template>

Now, I'd like to change the value of someValue to true and access my div with this.$.my, but as you expect, this.$.my is undefined.

Is this possible? How?

--
Leandro Rodrigo Saad Cruz

Eric Bidelman

unread,
Jul 18, 2014, 3:18:47 PM7/18/14
to webcom...@googlegroups.com
This is more appropriate for the polymer mailing list because it's using specific features, but to answer your question, this.$ only works with static nodes. See https://github.com/Polymer/docs/issues/460


--
You received this message because you are subscribed to the Google Groups "Web Components Organisation" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webcomponent...@googlegroups.com.
To post to this group, send email to webcom...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/webcomponents/CA%2BDnGt4wNb6Hh11Oa5Odx1j6Xp3tnd7bm53szRzs9kHKJDr9gw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Leandro Cruz

unread,
Jul 28, 2014, 11:20:01 AM7/28/14
to webcom...@googlegroups.com
Hi all. 

So far, the only solution to this problem is using calling 'this.shadowRoot.getElementById()' to access my child nodes when the attribute changes.

I guess is that, when an attribute changes, not only the event handler for template nodes have to be updated, but the handy this.$ map too.

--
Leandro Rodrigo Saad Cruz
Reply all
Reply to author
Forward
0 new messages