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

automatic node finding within a template-if #387

Closed
sigmundch opened this issue Jan 2, 2014 · 6 comments
Closed

automatic node finding within a template-if #387

sigmundch opened this issue Jan 2, 2014 · 6 comments
Assignees

Comments

@sigmundch
Copy link

Should the automatic node finding feature be able to find elements that are added conditionally, for example inside a template-if?

Here is an example that illustrates the issue. While both a and b input boxes are visible and can be found through shadowRoot.querySelector. Only a is found using the automatic node finding feature $:

<script src="platform/platform.js"></script>
<link rel="import" href="polymer/polymer.html">

<polymer-element name="x-test">
  <template>
    <input id="a" value="{{aValue}}">
    <template if="{{hasB}}"><input id="b" value="{{bValue}}"></template>
  </template>
</polymer-element>

<x-test></x-test>

<script>
Polymer('x-test', {
    aValue: 'a',
    hasB: true,
    bValue: 'b',
    enteredView: function() {
      // b is not visible here yet (waiting for bindings to propagate)
      var self = this;

      setTimeout(function () {
        // a is found just fine.
        console.log("a exists: " + !!self.shadowRoot.querySelector('#a'));
        console.log("a found: " + !!self.$.a);

        // b is visible here
        console.log("b exists: " + !!self.shadowRoot.querySelector('#b'));
        // but not available in $
        console.log("b found: " + !!self.$.b);
      }, 0);
    }
});
</script>

For additional details, see this discussion from a polymer.dart user:
https://groups.google.com/a/dartlang.org/d/msg/web/vRt2AxALmA0/ybaa8EUZf4AJ

@sethladd
Copy link

sethladd commented Jan 2, 2014

/sub

@justinfagnani
Copy link
Contributor

/sub+1

@ErikGrimes
Copy link

/sub

@tikurahul
Copy link

👍

@agrueneberg
Copy link

Would be useful for core-selector if the target sits in a conditional template.

@sjmiles
Copy link
Contributor

sjmiles commented Aug 18, 2014

See discussion #642

@sjmiles sjmiles closed this as completed Aug 18, 2014
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

7 participants