Skip to content

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

Description

@blasten

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').

Activity

  1. zoechi commented on May 11, 2015

    @zoechi

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

  2. blasten commented on May 11, 2015

    @blasten
    ContributorAuthor

    oh. I see good to know. Thanks!

  3. arthurevans commented on May 11, 2015

    @arthurevans

    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.

  4. blasten commented on May 12, 2015

    @blasten
    ContributorAuthor

    @arthurevans thanks!

  5. stevenjb commented on Nov 30, 2015

    @stevenjb

    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

Metadata

Metadata

Assignees

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