| 549 | | == [Reflect](a) FIXME == #Reflect |
| 550 | | |
| 551 | | Summary: ADD SUMMARY |
| 552 | | |
| 553 | | Usage: [Reflect] can be specified on attributes: |
| 554 | | {{{ |
| 555 | | attribute [Reflect] DOMString str; |
| 556 | | }}} |
| 557 | | |
| 558 | | ADD EXPLANATIONS |
| | 549 | == [Reflect](a) == #Reflect |
| | 550 | |
| | 551 | * [http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#reflect The spec of Reflect] |
| | 552 | |
| | 553 | Summary: [Reflect] indicates that a given attribute should reflect the values of a corresponding content attribute. |
| | 554 | |
| | 555 | Usage: The possible usage is [Reflect] or [Reflect=X], where X is the name of a corresponding content attribute. |
| | 556 | [Reflect] can be specified on attributes: |
| | 557 | {{{ |
| | 558 | interface Element { |
| | 559 | attribute [Reflect] DOMString id; |
| | 560 | attribute [Reflect=class] DOMString className; |
| | 561 | }; |
| | 562 | }}} |
| | 563 | |
| | 564 | (Informally speaking,) a content attribute means an attribute on an HTML tag: |
| | 565 | {{{ |
| | 566 | <div id="foo" class="fooClass"></div> |
| | 567 | }}} |
| | 568 | Here 'id' and 'class' are content attributes. |
| | 569 | |
| | 570 | If a given attribute in an IDL file is marked as [Reflect], |
| | 571 | it indicates that the attribute getter returns the value of the corresponding content attribute |
| | 572 | and that the attribute setter sets the value of the corresponding content attribute. |
| | 573 | In the above example, 'div.id' returns 'foo', and 'div.id = "bar"' sets "bar" to the 'id' content attribute. |
| | 574 | |
| | 575 | If the name of the corresponding content attribute is different from the attribute name in an IDL file, |
| | 576 | you can specify the content attribute name by [Reflect=X]. |
| | 577 | For example, in case of [Reflect=class], if 'div.className="barClass"' is evaluated, then "barClass" is set to the 'class' content attribute. |
| | 578 | |
| | 579 | Whether [Reflect] should be specified or not depends on the spec of each attribute. |