Skip to content

Commit c6e56d5

Browse files
committed
Merge branch 'prtksxna-doc'
2 parents 58883fe + aa30517 commit c6e56d5

File tree

2 files changed

+49
-49
lines changed

2 files changed

+49
-49
lines changed

docs/polymer/binding-types.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ subtitle: Data-binding
1212
There are several ways to bind data to a template. You can:
1313

1414
* Create a single instance of a template, by specifying a single object using the `bind` attribute.
15-
* Create multiple instances of a template, by specifying an array of objects using the `repeat`
15+
* Create multiple instances of a template, by specifying an array of objects using the `repeat`
1616
attribute.
1717
* Conditionally create an instance of a template, depending on whether the value passed to the `if`attribute is truthy.
1818

19-
**Note:** Binding templates only works inside {{site.project_title}} elements. For example, if a
20-
`<template>` element is inserted directly into a page’s `<body>` tag, the `bind` attribute
21-
doesn’t work as described here. If you need to use template binding outside of a
22-
{{site.project_title}} element, see [Using data binding outside of a {{site.project_title}} element](/docs/polymer/databinding-advanced.html#bindingoutside).
19+
**Note:** Binding templates only works inside {{site.project_title}} elements. For example, if a
20+
`<template>` element is inserted directly into a page’s `<body>` tag, the the `bind` attribute
21+
doesn’t work as described here. If you need to use template binding outside of a
22+
{{site.project_title}} element, see [Using data binding outside of a {{site.project_title}} element](/docs/polymer/databinding-advanced.html#bindingoutside).
2323
{: .alert .alert-info }
2424

25-
When you use a binding _inside_ a template, you create a _node binding_, which binds a model value to a
26-
DOM node. Node bindings are interpreted by the node, based on the element type and where the binding
25+
When you use a binding _inside_ a template, you create a _node binding_, which binds a model value to a
26+
DOM node. Node bindings are interpreted by the node, based on the element type and where the binding
2727
occurs. See [Node bindings](#node-bindings) for details.
2828

2929
## Single template instances
@@ -37,9 +37,9 @@ Using the `bind` attribute, you can create a single instance of a template bound
3737
</template>
3838
{% endraw %}
3939

40-
Where `person` is an object (or more accurately, a [{{site.project_title}} expression](#expressions) that yields an object).
40+
Where `person` is an object (or more accurately, a [{{site.project_title}} expression](/docs/polymer/expressions.html) that yields an object).
4141

42-
Bindings inside the template are evaluated in the context of the bound object. For example,
42+
Bindings inside the template are evaluated in the context of the bound object. For example,
4343
if `person` has a property, `name`, {%raw%}`{{name}}`{%endraw%} evaluates to the value of `person.name`.
4444

4545
For convenience, you can also create a _named scope_ when binding an object:
@@ -51,7 +51,7 @@ For convenience, you can also create a _named scope_ when binding an object:
5151
</template>
5252
{% endraw %}
5353

54-
In this case, you can use the named scope `p` to access the properties of the `person` object.
54+
In this case, you can use the named scope `p` to access the properties of the `person` object.
5555
Named scopes can be handy when nesting templates.
5656

5757

@@ -131,7 +131,7 @@ Conditional templates use the `if` attribute to conditionally create a template
131131
</template>
132132
{% endraw %}
133133

134-
The conditional template can be explicitly bound to an object using the
134+
The conditional template can be explicitly bound to an object using the
135135
{%raw%}`bind={{expression}}`{%endraw%} syntax.
136136

137137
Where the explicit binding is omitted, a nested template can inherit the scope of
@@ -145,7 +145,7 @@ the containing template. Conditional templates are frequently used this way:
145145
</template>
146146
{% endraw %}
147147

148-
For more information on nesting templates, see [Expression scopes](#expression-scopes).
148+
For more information on nesting templates, see [Expression scopes](/docs/polymer/expressions.html#expression-scopes).
149149

150150
You can also use `if` with the `repeat` attribute.
151151

@@ -157,9 +157,9 @@ You can also use `if` with the `repeat` attribute.
157157
</template>
158158
{% endraw %}
159159

160-
## Importing templates by reference
160+
## Importing templates by reference
161161

162-
Sometimes, you may want to reuse a template in multiple places, or reference a template generated elsewhere.
162+
Sometimes, you may want to reuse a template in multiple places, or reference a template generated elsewhere.
163163
That's where the `ref` attribute comes in:
164164

165165
{% raw %}
@@ -187,7 +187,7 @@ You can use the `ref` attribute to define recursive templates, such as tree stru
187187
</template>
188188
{% endraw %}
189189

190-
In addition, you can bind to the `ref` attribute _itself_, to choose templates dynamically:
190+
In addition, you can bind to the `ref` attribute _itself_, to choose templates dynamically:
191191

192192
{% raw %}
193193
<template bind ref="{{node.nodeType}}"></template>
@@ -205,13 +205,13 @@ How nodes interpret bindings depends on the _type of element_, and the _binding
205205

206206
### Binding to text
207207

208-
If a binding occurs between tags, it creates a `textContent` binding to the element.
208+
If a binding occurs between tags, it creates a `textContent` binding to the element.
209209

210210
{% raw %}
211211
<p>This paragraph has some {{adjective}} text.</p>
212212
{% endraw %}
213213

214-
All text nodes treat a `textContent` bindingas a one-way binding: changing the model changes the bound node, but imperatively changing the DOM value does _not_ update the model.
214+
All text nodes treat a `textContent` binding as a one-way binding: changing the model changes the bound node, but imperatively changing the DOM value does _not_ update the model.
215215

216216
### Binding to attributes
217217

@@ -244,7 +244,7 @@ Two-way bindings are supported as a special case on some user input elements. Sp
244244

245245
When you bind to a [published property](polymer.html#published-properties) on a {{site.project_title}} element, you get a two-way binding to the property.
246246

247-
In the following sample, the `intro-tag` binds to a published property on the `say-hello` element:
247+
In the following sample, the `intro-tag` binds to a published property on the `say-hello` element:
248248

249249
{% raw %}
250250
<!-- say-hello element publishes the 'name' property -->
@@ -273,19 +273,19 @@ In the following sample, the `intro-tag` binds to a published property on the `s
273273
{% endraw %}
274274

275275
Here, `yourName` is bound to _both_ the `say-hello` element's `name` property and
276-
the `input` element's `value` attribute. Both bindings are two-way, so when the user enters
277-
a name, it's pushed into the `say-hello` element's `name` property. If you change the
276+
the `input` element's `value` attribute. Both bindings are two-way, so when the user enters
277+
a name, it's pushed into the `say-hello` element's `name` property. If you change the
278278
value of the `name` property, the value is pushed into the `input` element.
279279

280-
**Note:** The `intro-tag` element doesn't define a `yourName` property. In this case, the data
280+
**Note:** The `intro-tag` element doesn't define a `yourName` property. In this case, the data
281281
binding system creates the property automatically.
282282
{: .alert .alert-info }
283283

284284

285285
#### Binding objects and arrays to published properties
286286

287-
Most of the examples show data binding with simple string values,
288-
but {{site.project_title}} lets you bind references between elements
287+
Most of the examples show data binding with simple string values,
288+
but {{site.project_title}} lets you bind references between elements
289289
using published properties.
290290

291291
Let's modify the `name-tag` example to take an object instead of individual
@@ -354,13 +354,12 @@ If _boolean-expression_ is truthy, _attribute_ appears in the markup; otherwise
354354

355355
Sometimes, you may not need dynamic bindings. For these cases, there are one-time bindings.
356356

357-
Anywhere you use {% raw %}`{{}}`{% endraw %} in expressions, you can use double brackets
357+
Anywhere you use {% raw %}`{{}}`{% endraw %} in expressions, you can use double brackets
358358
(`[[]]`) to set up a one-time binding. The binding becomes inactive after {{site.project_title}}
359359
sets its value for the first time.
360360

361361
Example:
362362

363363
<input type="text" value="this value is inserted once: [[ obj.value ]]">
364364

365-
One-time bindings can potentially be a performance win if you don't need the overhead of setting up property observation.
366-
365+
One time bindings can potentially be a performance win if you don't need the overhead of setting up property observation.

docs/polymer/polymer.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ At the heart of {{site.project_title}} are [Custom Elements](/platform/custom-el
2525

2626
### Attributes
2727

28-
{{site.project_title}} [reserves](https://github.com/Polymer/polymer/blob/master/src/declaration/attributes.js#L53) special attributes to be used on `<polymer-element>`:
28+
{{site.project_title}} reserves special attributes to be used on `<polymer-element>`:
2929

3030
<table class="table responsive-table attributes-table">
3131
<tr>
@@ -85,19 +85,19 @@ For convenient decoupling of script and markup, you don't have to inline your sc
8585
{{site.project_title}} elements can be created by referencing an external script
8686
which calls `Polymer('tag-name')`:
8787

88-
<!-- 2. Script referenced inside the element definition. -->
88+
<!-- 1. Script referenced inside the element definition. -->
8989
<polymer-element name="tag-name">
9090
<template>...</template>
9191
<script src="path/to/tagname.js"></script>
9292
</polymer-element>
9393

94-
<!-- 3. Script comes before the element definition. -->
94+
<!-- 2. Script comes before the element definition. -->
9595
<script src="path/to/tagname.js"></script>
9696
<polymer-element name="tag-name">
9797
<template>...</template>
9898
</polymer-element>
9999

100-
<!-- 4. No script -->
100+
<!-- 3. No script -->
101101
<polymer-element name="tag-name" constructor="TagName" noscript>
102102
<template>
103103
<!-- shadow DOM here -->
@@ -119,22 +119,22 @@ Elements can be registered in pure JavaScript like so:
119119
</polymer-element>';
120120
// The custom elements polyfill can't see the <polymer-element>
121121
// unless you put it in the DOM.
122-
document.body.appendChild(el);
122+
document.body.appendChild(el);
123123
</script>
124124

125125
<name-tag name="John"></name-tag>
126126

127-
Note that you need to add the `<polymer-element>` to the document so that the
127+
Note that you need to add the `<polymer-element>` to the document so that the
128128
Custom Elements polyfill picks it up.
129-
129+
130130
### Adding public properties and methods {#propertiesmethods}
131131

132132
If you wish to define methods/properties on your element (optional), pass an object
133133
as the second argument to `Polymer()`. This object is used to define
134134
the element's `prototype`.
135135

136136
The following example defines a property `message`, a computed property `greeting`
137-
using an ES5 getter, and a method `foo`:
137+
using an ES5 getter, and a method `foo`:
138138

139139
<polymer-element name="tag-name">
140140
<template>{{greeting}}</template>
@@ -143,7 +143,7 @@ using an ES5 getter, and a method `foo`:
143143
message: "Hello!",
144144
get greeting() {
145145
return this.message + ' there!';
146-
},
146+
},
147147
foo: function() {...}
148148
});
149149
</script>
@@ -152,7 +152,7 @@ using an ES5 getter, and a method `foo`:
152152
**Note:** `this` references the custom element itself inside a {{site.project_title}} element. For example, `this.localName == 'tag-name'`.
153153
{: .alert .alert-info }
154154

155-
**Important:** Be careful when initializing properties that are objects or arrays. Due to the nature of `prototype`, you may run into unexpected "shared state" across instances of the same element. If you're initializing an array or object, do it in the `created` callback rather than directly on the `prototype`.
155+
**Important:** Be careful when initializing properties that are objects or arrays. Due to the nature of `prototype`, you may run into unexpected "shared state" across instances of the same element. If you're initializing an array or object, do it in the `created` callback rather than directly on the `prototype`.
156156

157157
// Good!
158158
Polymer('x-foo', {
@@ -256,7 +256,7 @@ The main page configures the globals by passing attributes:
256256
{{site.project_title}} has first class support for the Custom Element lifecycle
257257
callbacks, though for convenience, implements them with shorter names.
258258

259-
All of the lifecycle callbacks are optional:
259+
All of the lifecycle callbacks are optional:
260260

261261
Polymer('tag-name', {
262262
created: function() { ... },
@@ -277,7 +277,7 @@ Spec | {{site.project_title}} | Called when
277277
|-
278278
createdCallback | created | An instance of the element is created.
279279
- | ready | The `<polymer-element>` has been fully prepared (e.g. Shadow DOM created, property observers setup, event listeners attached, etc).
280-
attachedCallback | attached | An instance of the element was inserted into the DOM.
280+
attachedCallback | attached | An instance of the element was inserted into the DOM.
281281
- | 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.
282282
detachedCallback | detached | An instance was removed from the DOM.
283283
attributeChangedCallback | attributeChanged | An attribute was added, removed, or updated. **Note**: to observe changes to [published properties](#published-properties), use [changed watchers](#change-watchers).
@@ -453,7 +453,7 @@ When attribute values are converted to property values, {{site.project_title}}
453453
attempts to convert the value to the correct type, depending on the default
454454
value of the property.
455455

456-
For example, suppose an `x-hint` element has a `count` property that defaults to `0`.
456+
For example, suppose an `x-hint` element has a `count` property that defaults to `0`.
457457

458458
<x-hint count="7"></x-hint>
459459

@@ -465,7 +465,7 @@ double-quoted JSON string. For example:
465465

466466
<x-name fullname='{ "first": "Bob", "last": "Dobbs" }'></x-name>
467467

468-
This is equivalent to setting the element's `fullname` property to an object
468+
This is equivalent to setting the element's `fullname` property to an object
469469
literal in JavaScript:
470470

471471
xname.fullname = { first: 'Bob', last: 'Dobbs' };
@@ -648,7 +648,7 @@ All properties on {{site.project_title}} elements can be watched for changes by
648648
</script>
649649
</polymer-element>
650650

651-
In this example, there are two watched properties, `better` and `best`. The `betterChanged` and `bestChanged` function will be called whenever `better` or `best` are modified, respectively.
651+
In this example, there are two watched properties, `better` and `best`. The `betterChanged` and `bestChanged` function will be called whenever `better` or `best` are modified, respectively.
652652

653653
#### Custom property observers - `observe` blocks {#observeblock}
654654

@@ -734,7 +734,7 @@ It's important to note that **{{site.project_title}} does not call the <code><em
734734

735735
### Automatic node finding
736736

737-
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.
737+
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.
738738

739739
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`.
740740

@@ -762,7 +762,7 @@ Example:
762762
{% raw %}
763763
<polymer-element name="ouch-button">
764764
<template>
765-
<button on-click="{{onClick}}">Send hurt</button>
765+
<button on-click="{{onClick}}">Send hurt</button>
766766
</template>
767767
<script>
768768
Polymer('ouch-button', {
@@ -806,7 +806,7 @@ and data-bound.
806806
<polymer-element name="polymer-cooler" extends="polymer-cool">
807807
<template>
808808
<!-- A shadow element render's the extended
809-
element's shadow dom here. -->
809+
element's shadow dom here. -->
810810
<shadow></shadow> <!-- "You are cool Matt" -->
811811
</template>
812812
<script>
@@ -864,8 +864,8 @@ to "coolest".
864864

865865
### Observing changes to light DOM children {#onMutation}
866866

867-
To know when light DOM children change, you can setup a Mutation Observer to
868-
be notified when nodes are added or removed. To make this more convenient, {{site.project_title}} adds an `onMutation()` callback to every element. Its first argument is the DOM element to
867+
To know when light DOM children change, you can setup a Mutation Observer to
868+
be notified when nodes are added or removed. To make this more convenient, {{site.project_title}} adds an `onMutation()` callback to every element. Its first argument is the DOM element to
869869
observe. The second argument is a callback which is passed the `MutationObserver` and the mutation records:
870870

871871
this.onMutation(domElement, someCallback);
@@ -953,7 +953,7 @@ declared in markup.
953953

954954
If you instantiate an element (e.g. `document.createElement('x-foo')`) and do **not** add it to the DOM,
955955
{{site.project_title}} asynchronously removes its {%raw%}`{{}}`{%endraw%} bindings and `*Changed` methods.
956-
This helps prevent memory leaks, ensuring the element will be garbage collected.
956+
This helps prevent memory leaks, ensuring the element will be garbage collected.
957957

958958
If you want the element to "remain active" when it's not in the `document`,
959959
call `cancelUnbindAll()` right after you create or remove it. The [lifecycle methods](#lifecyclemethods)
@@ -998,7 +998,7 @@ when `Object.observe()` is available. When it's not supported, {{site.project_ti
998998

999999
`Platform.flush()` is part of {{site.project_title}}'s data observation polyfill, [observe-js](https://github.com/Polymer/observe-js). It dirty check's all objects that have been observed and ensures notification callbacks are dispatched. {{site.project_title}} automatically calls `Platform.flush()` periodically, and this should be sufficient for most application workflows. However, there are times when you'll want to call `Platform.flush()` in application code.
10001000

1001-
**Note**: on platforms that support `Object.observe()` natively, `Platform.flush()` does nothing.
1001+
**Note:** on platforms that support `Object.observe()` natively, `Platform.flush()` does nothing.
10021002
{: .alert .alert-info }
10031003

10041004
#### When should I call `Platform.flush()`?
@@ -1012,6 +1012,7 @@ need to manually call `Platform.flush()`. Here are specific examples:
10121012
2. The author of a slider element wants to ensure that data can propagate from it as the user slides the slider. A user of the element, might, for example, bind the slider's value to an input and expect to see the input change while the slider is moving. To achieve this, the element author calls `Platform.flush()` after setting the element's value in the `ontrack` event handler.
10131013

10141014
**Note:** {{site.project_title}} is designed such that change notifications are asynchronous. Both `Platform.flush()` and `Object.observe()` (after which it's modeled) are asynchronous. Therefore, **`Platform.flush()` should not be used to try to enforce synchronous data notifications**. Instead, always use [change watchers](#change-watchers) to be informed about state.
1015+
{: .alert .alert-info }
10151016

10161017
### How {{site.project_title}} elements prepare themselves {#prepare}
10171018

@@ -1037,7 +1038,7 @@ prepare themselves even when they do not satisfy the above rules.
10371038

10381039
### Resolving paths of sibling elements {#resolvepath}
10391040

1040-
For the general case of element re-use and sharing, URLs in HTML Imports are meant to be relative to the location of the import. The majority of the time, the browser takes care of this for you.
1041+
For the general case of element re-use and sharing, URLs in HTML Imports are meant to be relative to the location of the import. The majority of the time, the browser takes care of this for you.
10411042

10421043
However, JavaScript doesn't have a notion of a local import. Therefore, {{site.project_title}} provides a `resolvePath()` utility for converting paths relative to the import to paths relative to the document.
10431044

0 commit comments

Comments
 (0)