Skip to content

Commit 9a049d9

Browse files
committed
Merge pull request react#675 from chenglou/special-attrs
docs section for non-dom attributes and more in dom differences
2 parents 294bac5 + 47f2cac commit 9a049d9

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

docs/_data/nav_docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@
5555
title: Event System
5656
- id: dom-differences
5757
title: DOM Differences
58+
- id: special-non-dom-attributes
59+
title: Special Non-DOM attributes

docs/docs/ref-04-tags-and-attributes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ rowSpan scrollLeft scrollTop selected size spellCheck src step style tabIndex
5757
target title type value width wmode
5858
```
5959

60-
In addition, the non-standard `autoCapitalize` attribute is supported for Mobile Safari.
60+
The non-standard `autoCapitalize` attribute is supported for Mobile Safari.
61+
62+
In addition, there is the React-specific attribute `dangerouslySetInnerHTML` ([more here](/react/docs/special-non-dom-attributes.html)), used for directly inserting DOM strings into a component.
6163

6264
### SVG Attributes
6365

docs/docs/ref-06-dom-differences.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: DOM Differences
44
layout: docs
55
permalink: dom-differences.html
66
prev: events.html
7+
next: special-non-dom-attributes.html
78
---
89

910
React has implemented a browser-independent events and DOM system for performance and cross-browser compatibility reasons. We took the opportunity to clean up a few rough edges in browser DOM implementations.
@@ -12,3 +13,4 @@ React has implemented a browser-independent events and DOM system for performanc
1213
* The `style` attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM `style` JavaScript property, is more efficient, and prevents XSS security holes.
1314
* All event objects conform to the W3C spec, and all events (including submit) bubble correctly per the W3C spec. See [Event System](events.html) for more details.
1415
* The `onChange` event behaves as you would expect it to: whenever a form field is changed this event is fired rather than inconsistently on blur. We intentionally break from existing browser behavior because `onChange` is a misnomer for its behavior and React relies on this event to react to user input in real time. See [Forms](forms.html) for more details.
16+
* Form input attributes such as `value` and `checked`, as well as `textarea`. [More here](/react/docs/forms.html).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
id: special-non-dom-attributes
3+
title: Special Non-DOM Attributes
4+
layout: docs
5+
permalink: special-non-dom-attributes.html
6+
prev: dom-differences.html
7+
---
8+
9+
Beside [DOM differences](/react/docs/dom-differences.html), React offers some attributes that simply don't exist in DOM.
10+
11+
- `key`: an optional, unique identifier. When your component shuffles around during `render` passes, it might be destroyed and recreated due to the diff algorithm. Assigning it a key that persists makes sure the component stays. See more [here](/react/docs/multiple-components.html#dynamic-children).
12+
- `ref`: see [here](/react/docs/more-about-refs.html).
13+
- `dangerouslySetInnerHTML`: takes an object with the key `__html` and a DOM string as value. This is mainly for cooperating with DOM string manipulation libraries. Refer to the last example on the front page.

0 commit comments

Comments
 (0)