Skip to content

Commit

Permalink
📖 Add docs for XML-compatible AMP bind attribute syntax (#19835)
Browse files Browse the repository at this point in the history
* Add docs for XML-compatible binding attribute syntax

See #11115 and #15408

* Minor edits
  • Loading branch information
westonruter authored and William Chou committed Jan 16, 2019
1 parent 049f005 commit e45b6f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions extensions/amp-bind/amp-bind.md
Expand Up @@ -79,7 +79,7 @@ For performance and to avoid the risk of unexpected content jumping, `amp-bind`
1. [State](#state): A document-scope, mutable JSON state. In the example above, the state is empty before tapping the button. After tapping the button, the state is `{foo: 'amp-bind'}`.
2. [Expressions](#expressions): These are JavaScript-like expressions that can reference the **state**. The example above has a single expression, `'Hello ' + foo`, which concatenates the string literal `'Hello '` and the state variable `foo`.
There is a limit of 100 operands what can be used in an expression.
3. [Bindings](#bindings): These are special attributes of the form `[property]` that link an element's property to an **expression**. The example above has a single binding, `[text]`, which updates the `<p>` element's text every time the expression's value changes.
3. [Bindings](#bindings): These are special attributes of the form `[property]` that link an element's property to an **expression**. The example above has a single binding, `[text]`, which updates the `<p>` element's text every time the expression's value changes.

`amp-bind` takes special care to ensure speed, security and performance on AMP pages.

Expand Down Expand Up @@ -360,7 +360,7 @@ A macro can also call other macros <i>defined before itself</i>. A macro cannot

### Bindings

A **binding** is a special attribute of the form `[property]` that links an element's property to an [expression](#expressions).
A **binding** is a special attribute of the form `[property]` that links an element's property to an [expression](#expressions). An alternative, XML-compatible syntax can also be used in the form of `data-amp-bind-property`.

When the **state** changes, expressions are re-evaluated and the bound elements' properties are updated with the new expression results.

Expand Down Expand Up @@ -399,12 +399,12 @@ When the **state** changes, expressions are re-evaluated and the bound elements'
</tr>
</table>

Notes on Bindings:
Notes on bindings:

- For security reasons, binding to `innerHTML` is disallowed.
- All attribute bindings are sanitized for unsafe values (e.g., `javascript:`).
- Boolean expression results toggle boolean attributes. For example: `<amp-video [controls]="expr"...>`. When `expr` evaluates to `true`, the `<amp-video>` element has the `controls` attribute. When `expr` evaluates to `false`, the `controls` attribute is removed.

- Bracket characters `[` and `]` in attribute names can be problematic when writing XML (e.g. XHTML, JSX) or writing attributes via DOM APIs. In these cases, use the alternative syntax `data-amp-bind-x="foo"` instead of `[x]="foo"`.

#### Element-specific attributes

Expand Down

0 comments on commit e45b6f4

Please sign in to comment.