You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ Polymer docs are mostly in Markdown with some HTML. [Jekyll][jekyll] is used to
5
5
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/)):
| Function | `reverse(my_list)` | The expression's value is the return value of the function. The function's arguments are observed for changes, and the expression is re-evaluated whenever one of the arguments changes.
Copy file name to clipboardExpand all lines: docs/polymer/polymer.md
+59-3Lines changed: 59 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -133,7 +133,7 @@ If you wish to define methods/properties on your element (optional), pass an obj
133
133
as the second argument to `Polymer()`. This object is used to define
134
134
the element's `prototype`.
135
135
136
-
The following example defines a property `message`, a computed property `greeting`
136
+
The following example defines a property `message`, a property `greeting`
137
137
using an ES5 getter, and a method `foo`:
138
138
139
139
<polymer-element name="tag-name">
@@ -278,7 +278,7 @@ Below is a table of the lifecycle methods according to the Custom Elements
278
278
Spec | {{site.project_title}} | Called when
279
279
|-
280
280
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).
282
282
attachedCallback | attached | An instance of the element was inserted into the DOM.
283
283
- | 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.
284
284
detachedCallback | detached | An instance was removed from the DOM.
@@ -599,6 +599,37 @@ In this example, the published property `name` has initial value of `null` and `
599
599
600
600
For more information see the [Data binding overview](databinding.html).
601
601
602
+
### Computed properties
603
+
604
+
In addition to standard published properties, you can define
605
+
properties that are computed based on other property values.
606
+
607
+
Computed properties are defined in the `computed` object on the
Each computed property is defined by a property name and a
617
+
[Polymer expression](/docs/polymer/expressions.html). The value
618
+
of the computed property is updated dynamically whenever one of
619
+
the input values in the expression changes.
620
+
621
+
In the following example, when you update the input value,
622
+
`num`, the computed property `square` updates automatically.
623
+
624
+
{% include samples/computed-property.html %}
625
+
626
+
**Limitations**: Currently, computed properties aren't published
627
+
so they can't be data bound from _outside_ the element. For example,
628
+
you can't bind to the `square` property on `square-element` using
629
+
`<square-element square="{%raw%}{{value}}{%endraw%}>`. This
630
+
is [a known issue](https://github.com/Polymer/polymer/issues/638).
631
+
{: .alert .alert-warning }
632
+
602
633
### Declarative event mapping
603
634
604
635
{{site.project_title}} supports declarative binding of events to methods in the component.
@@ -736,7 +767,14 @@ It's important to note that **{{site.project_title}} does not call the <code><em
736
767
737
768
### Automatic node finding
738
769
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.
770
+
Another useful feature of {{site.project_title}} is automatic node finding.
771
+
Nodes in a component's shadow DOM that are tagged with an
772
+
`id` attribute are automatically referenced in the component's `this.$` hash.
773
+
774
+
**Note:** Nodes created dynamically using data binding are _not_ added to the
775
+
`this.$` hash. The hash includes only _statically_ created shadow DOM nodes
776
+
(that is, the nodes defined in the element's outermost template).
777
+
{: .alert .alert-warning }
740
778
741
779
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`.
742
780
@@ -753,6 +791,24 @@ For example, the following defines a component whose template contains an `<inpu
753
791
</script>
754
792
</polymer-element>
755
793
794
+
To locate other nodes inside the element's shadow DOM, you can create a
795
+
container element with a known ID and use `querySelector` to retrieve
796
+
descendants. For example, if your element's template looks like this:
0 commit comments