Skip to content

Commit 5bf4edb

Browse files
committed
Merge pull request Polymer#562 from arthurevans/docs-460
Add note that this.$ only contains static IDs (not databound nodes).
2 parents 93557ce + 08b6d30 commit 5bf4edb

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Polymer docs are mostly in Markdown with some HTML. [Jekyll][jekyll] is used to
55
We use Jekyll 2.0+ and [Grunt][grunt] to generate the documentation, and compass to compile SASS to CSS. You'll need to install the requirements before working on the docs (these instructions assume [NPM is already installed](http://nodejs.org/download/)):
66

77
gem install jekyll kramdown jekyll-page-hooks compass rouge
8-
npm install -g grunt-cli
8+
npm install -g grunt-cli vulcanize
99

1010
**Note:** If you receive permission warnings, you may need to run the above tasks with `sudo`.
1111

docs/polymer/polymer.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Below is a table of the lifecycle methods according to the Custom Elements
278278
Spec | {{site.project_title}} | Called when
279279
|-
280280
createdCallback | created | An instance of the element is created.
281-
- | ready | The `<polymer-element>` has been fully prepared (e.g. Shadow DOM created, property observers setup, event listeners attached, etc).
281+
- | ready | The `<polymer-element>` has been fully prepared (e.g. shadow DOM created, property observers setup, event listeners attached, etc).
282282
attachedCallback | attached | An instance of the element was inserted into the DOM.
283283
- | domReady | Called when the element's initial set of children are guaranteed to exist. This is an appropriate time to poke at the element's parent or light DOM children. Another use is when you have sibling custom elements (e.g. they're `.innerHTML`'d together, at the same time). Before element A can use B's API/properties, element B needs to be upgraded. The `domReady` callback ensures both elements exist.
284284
detachedCallback | detached | An instance was removed from the DOM.
@@ -736,7 +736,14 @@ It's important to note that **{{site.project_title}} does not call the <code><em
736736

737737
### Automatic node finding
738738

739-
Another useful feature of {{site.project_title}} is node reference marshalling. Every node in a component's shadow DOM that is tagged with an `id` attribute is automatically referenced in the component's `this.$` hash.
739+
Another useful feature of {{site.project_title}} is automatic node finding.
740+
Nodes in a component's shadow DOM that are tagged with an
741+
`id` attribute are automatically referenced in the component's `this.$` hash.
742+
743+
**Note:** Nodes created dynamically using data binding are _not_ added to the
744+
`this.$` hash. The hash includes only _statically_ created shadow DOM nodes
745+
(that is, the nodes defined in the element's outermost template).
746+
{: .alert .alert-warning }
740747

741748
For example, the following defines a component whose template contains an `<input>` element whose `id` attribute is `nameInput`. The component can refer to that element with the expression `this.$.nameInput`.
742749

@@ -753,6 +760,24 @@ For example, the following defines a component whose template contains an `<inpu
753760
</script>
754761
</polymer-element>
755762

763+
To locate other nodes inside the element's shadow DOM, you can create a
764+
container element with a known ID and use `querySelector` to retrieve
765+
descendants. For example, if your element's template looks like this:
766+
767+
<template>
768+
<div id="container">
769+
<template if="{%raw%}{{some_condition}}{%endraw%}">
770+
<div id="inner">
771+
This content is created by data binding.
772+
</div>
773+
</template>
774+
</div>
775+
</template>
776+
777+
You can locate the inner container using:
778+
779+
this.$.container.querySelector('#inner');
780+
756781
### Firing custom events {#fire}
757782

758783
{{site.project_title}} core provides a convenient `fire()` method for

0 commit comments

Comments
 (0)