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

this.$.* isn't set if an element * is inside a dom-if block and the condition evaluates to true #1513

Closed
blasten opened this issue May 11, 2015 · 5 comments
Assignees

Comments

@blasten
Copy link
Contributor

blasten commented May 11, 2015

If I have the following code:

<template is="dom-if" if="[[editable]]">
      <paper-input id="input"></paper-input>
</template>

but this.$.input is always undefined even if editable === true. I found a workaround using this.$$('#input').

@zoechi
Copy link

zoechi commented May 11, 2015

This is by design and mentioned in the Polymer docs. $ supports only access to statically added elements (no if/repeat or imperatively added elements) .

@blasten
Copy link
Contributor Author

blasten commented May 11, 2015

oh. I see good to know. Thanks!

@blasten blasten closed this as completed May 11, 2015
@arthurevans
Copy link

This is a documented limitation of this.$:

https://www.polymer-project.org/0.8/docs/devguide/local-dom.html#node-finding

(Need to make this clearer; we emphasized it more in the 0.5 docs.)

Apparently we don't document this.$$ (I just heard of it now), so I'm adding that, too.

@blasten
Copy link
Contributor Author

blasten commented May 12, 2015

@arthurevans thanks!

@stevenjb
Copy link

I discovered this the hard way. It might be nice to add an additional note in the dom-if and dom-repat documentation warning developers about this, given how common usage of this.$. is in the examples I have seen.

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

5 participants