react 0.14.7 → 0.15.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/LICENSE +1 -1
  2. package/dist/react-with-addons.js +2937 -3414
  3. package/dist/react-with-addons.min.js +7 -7
  4. package/dist/react.js +2762 -3034
  5. package/dist/react.min.js +7 -7
  6. package/lib/AutoFocusUtils.js +3 -15
  7. package/lib/BeforeInputEventPlugin.js +8 -25
  8. package/lib/CSSProperty.js +3 -1
  9. package/lib/CSSPropertyOperations.js +20 -6
  10. package/lib/CallbackQueue.js +12 -1
  11. package/lib/ChangeEventPlugin.js +58 -54
  12. package/lib/DOMChildrenOperations.js +21 -60
  13. package/lib/DOMLazyTree.js +95 -0
  14. package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
  15. package/lib/DOMProperty.js +7 -2
  16. package/lib/DOMPropertyOperations.js +66 -36
  17. package/lib/Danger.js +6 -7
  18. package/lib/DefaultEventPluginOrder.js +1 -1
  19. package/lib/EnterLeaveEventPlugin.js +24 -43
  20. package/lib/EventConstants.js +2 -1
  21. package/lib/EventPluginHub.js +15 -59
  22. package/lib/EventPluginRegistry.js +23 -2
  23. package/lib/EventPluginUtils.js +60 -35
  24. package/lib/EventPropagators.js +19 -17
  25. package/lib/FallbackCompositionState.js +1 -2
  26. package/lib/HTMLDOMPropertyConfig.js +21 -23
  27. package/lib/LinkedInput.js +49 -0
  28. package/lib/LinkedStateMixin.js +1 -2
  29. package/lib/LinkedValueUtils.js +1 -2
  30. package/lib/MetaMatchers.js +2 -2
  31. package/lib/Object.assign.js +1 -1
  32. package/lib/OrderedMap.js +1 -1
  33. package/lib/PooledClass.js +1 -1
  34. package/lib/React.js +1 -13
  35. package/lib/ReactBrowserEventEmitter.js +3 -23
  36. package/lib/ReactCSSTransitionGroup.js +1 -2
  37. package/lib/ReactCSSTransitionGroupChild.js +1 -6
  38. package/lib/ReactChildReconciler.js +12 -10
  39. package/lib/ReactChildren.js +3 -3
  40. package/lib/ReactClass.js +18 -67
  41. package/lib/ReactComponent.js +2 -5
  42. package/lib/ReactComponentBrowserEnvironment.js +9 -6
  43. package/lib/ReactComponentEnvironment.js +3 -3
  44. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  45. package/lib/ReactCompositeComponent.js +94 -29
  46. package/lib/ReactCurrentOwner.js +1 -1
  47. package/lib/ReactDOM.js +26 -14
  48. package/lib/ReactDOMButton.js +2 -2
  49. package/lib/ReactDOMComponent.js +156 -218
  50. package/lib/ReactDOMComponentFlags.js +18 -0
  51. package/lib/ReactDOMComponentTree.js +186 -0
  52. package/lib/ReactDOMContainerInfo.js +32 -0
  53. package/lib/ReactDOMDebugTool.js +69 -0
  54. package/lib/ReactDOMEmptyComponent.js +61 -0
  55. package/lib/ReactDOMFactories.js +1 -2
  56. package/lib/ReactDOMFeatureFlags.js +2 -2
  57. package/lib/ReactDOMIDOperations.js +5 -60
  58. package/lib/ReactDOMInput.js +52 -23
  59. package/lib/ReactDOMInstrumentation.js +16 -0
  60. package/lib/ReactDOMOption.js +9 -8
  61. package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +57 -0
  62. package/lib/ReactDOMSelect.js +35 -14
  63. package/lib/ReactDOMSelection.js +2 -2
  64. package/lib/ReactDOMServer.js +1 -1
  65. package/lib/ReactDOMTextComponent.js +41 -21
  66. package/lib/ReactDOMTextarea.js +32 -5
  67. package/lib/ReactDOMTreeTraversal.js +134 -0
  68. package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
  69. package/lib/ReactDefaultBatchingStrategy.js +1 -1
  70. package/lib/ReactDefaultInjection.js +11 -15
  71. package/lib/ReactDefaultPerf.js +49 -19
  72. package/lib/ReactDefaultPerfAnalysis.js +16 -9
  73. package/lib/ReactElement.js +9 -5
  74. package/lib/ReactElementValidator.js +1 -1
  75. package/lib/ReactEmptyComponent.js +8 -29
  76. package/lib/ReactErrorUtils.js +1 -2
  77. package/lib/ReactEventEmitterMixin.js +3 -8
  78. package/lib/ReactEventListener.js +20 -75
  79. package/lib/ReactFeatureFlags.js +21 -0
  80. package/lib/ReactFragment.js +2 -2
  81. package/lib/ReactInjection.js +3 -3
  82. package/lib/ReactInputSelection.js +3 -3
  83. package/lib/ReactInstanceHandles.js +4 -6
  84. package/lib/ReactInstanceMap.js +1 -1
  85. package/lib/ReactIsomorphic.js +1 -1
  86. package/lib/ReactLink.js +1 -2
  87. package/lib/ReactMarkupChecksum.js +1 -1
  88. package/lib/ReactMount.js +67 -445
  89. package/lib/ReactMultiChild.js +104 -198
  90. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  91. package/lib/ReactNativeComponent.js +1 -1
  92. package/lib/ReactNodeTypes.js +37 -0
  93. package/lib/ReactNoopUpdateQueue.js +1 -24
  94. package/lib/ReactOwner.js +1 -1
  95. package/lib/ReactPerf.js +1 -2
  96. package/lib/ReactPropTransferer.js +1 -1
  97. package/lib/ReactPropTypeLocationNames.js +1 -1
  98. package/lib/ReactPropTypeLocations.js +1 -1
  99. package/lib/ReactPropTypes.js +8 -2
  100. package/lib/ReactReconcileTransaction.js +17 -6
  101. package/lib/ReactReconciler.js +14 -5
  102. package/lib/ReactRef.js +1 -1
  103. package/lib/ReactServerBatchingStrategy.js +1 -2
  104. package/lib/ReactServerRendering.js +15 -33
  105. package/lib/ReactServerRenderingTransaction.js +8 -26
  106. package/lib/ReactSimpleEmptyComponent.js +37 -0
  107. package/lib/ReactStateSetters.js +1 -1
  108. package/lib/ReactTestUtils.js +25 -15
  109. package/lib/ReactTransitionChildMapping.js +1 -2
  110. package/lib/ReactTransitionEvents.js +1 -1
  111. package/lib/ReactTransitionGroup.js +1 -1
  112. package/lib/ReactUpdateQueue.js +4 -4
  113. package/lib/ReactUpdates.js +19 -2
  114. package/lib/ReactVersion.js +2 -2
  115. package/lib/ReactWithAddons.js +1 -3
  116. package/lib/ResponderEventPlugin.js +53 -65
  117. package/lib/ResponderSyntheticEvent.js +1 -2
  118. package/lib/ResponderTouchHistoryStore.js +1 -1
  119. package/lib/SVGDOMPropertyConfig.js +2 -39
  120. package/lib/SelectEventPlugin.js +13 -18
  121. package/lib/SimpleEventPlugin.js +18 -16
  122. package/lib/SyntheticClipboardEvent.js +1 -2
  123. package/lib/SyntheticCompositionEvent.js +1 -2
  124. package/lib/SyntheticDragEvent.js +1 -2
  125. package/lib/SyntheticEvent.js +10 -7
  126. package/lib/SyntheticFocusEvent.js +1 -2
  127. package/lib/SyntheticInputEvent.js +1 -2
  128. package/lib/SyntheticKeyboardEvent.js +1 -2
  129. package/lib/SyntheticMouseEvent.js +1 -2
  130. package/lib/SyntheticTouchEvent.js +1 -2
  131. package/lib/SyntheticUIEvent.js +1 -2
  132. package/lib/SyntheticWheelEvent.js +1 -2
  133. package/lib/TapEventPlugin.js +3 -12
  134. package/lib/Transaction.js +1 -1
  135. package/lib/ViewportMetrics.js +1 -1
  136. package/lib/accumulate.js +1 -1
  137. package/lib/accumulateInto.js +1 -1
  138. package/lib/adler32.js +3 -2
  139. package/lib/canDefineProperty.js +1 -1
  140. package/lib/createHierarchyRenderer.js +1 -1
  141. package/lib/dangerousStyleValue.js +25 -3
  142. package/lib/deprecated.js +1 -1
  143. package/lib/escapeTextContentForBrowser.js +1 -1
  144. package/lib/findDOMNode.js +15 -8
  145. package/lib/flattenChildren.js +1 -1
  146. package/lib/forEachAccumulated.js +1 -1
  147. package/lib/getEventCharCode.js +1 -2
  148. package/lib/getEventKey.js +1 -2
  149. package/lib/getEventModifierState.js +1 -2
  150. package/lib/getEventTarget.js +1 -2
  151. package/lib/getIteratorFn.js +1 -2
  152. package/lib/getNativeComponentFromComposite.js +30 -0
  153. package/lib/getNodeForCharacterOffset.js +1 -1
  154. package/lib/getTestDocument.js +1 -1
  155. package/lib/getTextContentAccessor.js +1 -1
  156. package/lib/instantiateReactComponent.js +3 -4
  157. package/lib/isEventSupported.js +1 -1
  158. package/lib/isTextInputElement.js +1 -1
  159. package/lib/onlyChild.js +1 -1
  160. package/lib/quoteAttributeValueForBrowser.js +1 -1
  161. package/lib/reactComponentExpect.js +1 -1
  162. package/lib/renderSubtreeIntoContainer.js +1 -1
  163. package/lib/setInnerHTML.js +1 -1
  164. package/lib/setTextContent.js +1 -1
  165. package/lib/shallowCompare.js +1 -1
  166. package/lib/shouldUpdateReactComponent.js +1 -3
  167. package/lib/sliceChildren.js +1 -1
  168. package/lib/traverseAllChildren.js +6 -6
  169. package/lib/update.js +1 -1
  170. package/lib/validateDOMNesting.js +8 -9
  171. package/package.json +2 -2
  172. package/lib/ReactBrowserComponentMixin.js +0 -36
  173. package/lib/ReactEmptyComponentRegistry.js +0 -48
  174. package/lib/ReactRootIndex.js +0 -29
  175. package/lib/ServerReactRootIndex.js +0 -29
  176. package/lib/cloneWithProps.js +0 -54
  177. package/lib/webcomponents.js +0 -6379
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,18 +7,21 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule DOMChildrenOperations
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
14
13
 
14
+ var DOMLazyTree = require('./DOMLazyTree');
15
15
  var Danger = require('./Danger');
16
16
  var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
17
17
  var ReactPerf = require('./ReactPerf');
18
18
 
19
19
  var setInnerHTML = require('./setInnerHTML');
20
20
  var setTextContent = require('./setTextContent');
21
- var invariant = require('fbjs/lib/invariant');
21
+
22
+ function getNodeAfter(parentNode, node) {
23
+ return node ? node.nextSibling : parentNode.firstChild;
24
+ }
22
25
 
23
26
  /**
24
27
  * Inserts `childNode` as a child of `parentNode` at the `index`.
@@ -28,17 +31,15 @@ var invariant = require('fbjs/lib/invariant');
28
31
  * @param {number} index Index at which to insert the child.
29
32
  * @internal
30
33
  */
31
- function insertChildAt(parentNode, childNode, index) {
32
- // By exploiting arrays returning `undefined` for an undefined index, we can
33
- // rely exclusively on `insertBefore(node, null)` instead of also using
34
- // `appendChild(node)`. However, using `undefined` is not allowed by all
35
- // browsers so we must replace it with `null`.
36
-
37
- // fix render order error in safari
38
- // IE8 will throw error when index out of list size.
39
- var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index);
34
+ function insertChildAt(parentNode, childNode, referenceNode) {
35
+ // We rely exclusively on `insertBefore(node, null)` instead of also using
36
+ // `appendChild(node)`. (Using `undefined` is not allowed by all browsers so
37
+ // we are careful to use `null`.)
38
+ parentNode.insertBefore(childNode, referenceNode);
39
+ }
40
40
 
41
- parentNode.insertBefore(childNode, beforeChild);
41
+ function insertLazyTreeChildAt(parentNode, childTree, referenceNode) {
42
+ DOMLazyTree.insertTreeBefore(parentNode, childTree, referenceNode);
42
43
  }
43
44
 
44
45
  /**
@@ -55,66 +56,26 @@ var DOMChildrenOperations = {
55
56
  * update configurations are each expected to have a `parentNode` property.
56
57
  *
57
58
  * @param {array<object>} updates List of update configurations.
58
- * @param {array<string>} markupList List of markup strings.
59
59
  * @internal
60
60
  */
61
- processUpdates: function (updates, markupList) {
62
- var update;
63
- // Mapping from parent IDs to initial child orderings.
64
- var initialChildren = null;
65
- // List of children that will be moved or removed.
66
- var updatedChildren = null;
67
-
68
- for (var i = 0; i < updates.length; i++) {
69
- update = updates[i];
70
- if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING || update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
71
- var updatedIndex = update.fromIndex;
72
- var updatedChild = update.parentNode.childNodes[updatedIndex];
73
- var parentID = update.parentID;
74
-
75
- !updatedChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processUpdates(): Unable to find child %s of element. This ' + 'probably means the DOM was unexpectedly mutated (e.g., by the ' + 'browser), usually due to forgetting a <tbody> when using tables, ' + 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' + 'in an <svg> parent. Try inspecting the child nodes of the element ' + 'with React ID `%s`.', updatedIndex, parentID) : invariant(false) : undefined;
76
-
77
- initialChildren = initialChildren || {};
78
- initialChildren[parentID] = initialChildren[parentID] || [];
79
- initialChildren[parentID][updatedIndex] = updatedChild;
80
-
81
- updatedChildren = updatedChildren || [];
82
- updatedChildren.push(updatedChild);
83
- }
84
- }
85
-
86
- var renderedMarkup;
87
- // markupList is either a list of markup or just a list of elements
88
- if (markupList.length && typeof markupList[0] === 'string') {
89
- renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
90
- } else {
91
- renderedMarkup = markupList;
92
- }
93
-
94
- // Remove updated children first so that `toIndex` is consistent.
95
- if (updatedChildren) {
96
- for (var j = 0; j < updatedChildren.length; j++) {
97
- updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
98
- }
99
- }
100
-
61
+ processUpdates: function (parentNode, updates) {
101
62
  for (var k = 0; k < updates.length; k++) {
102
- update = updates[k];
63
+ var update = updates[k];
103
64
  switch (update.type) {
104
65
  case ReactMultiChildUpdateTypes.INSERT_MARKUP:
105
- insertChildAt(update.parentNode, renderedMarkup[update.markupIndex], update.toIndex);
66
+ insertLazyTreeChildAt(parentNode, update.content, getNodeAfter(parentNode, update.afterNode));
106
67
  break;
107
68
  case ReactMultiChildUpdateTypes.MOVE_EXISTING:
108
- insertChildAt(update.parentNode, initialChildren[update.parentID][update.fromIndex], update.toIndex);
69
+ insertChildAt(parentNode, update.fromNode, getNodeAfter(parentNode, update.afterNode));
109
70
  break;
110
71
  case ReactMultiChildUpdateTypes.SET_MARKUP:
111
- setInnerHTML(update.parentNode, update.content);
72
+ setInnerHTML(parentNode, update.content);
112
73
  break;
113
74
  case ReactMultiChildUpdateTypes.TEXT_CONTENT:
114
- setTextContent(update.parentNode, update.content);
75
+ setTextContent(parentNode, update.content);
115
76
  break;
116
77
  case ReactMultiChildUpdateTypes.REMOVE_NODE:
117
- // Already removed by the for-loop above.
78
+ parentNode.removeChild(update.fromNode);
118
79
  break;
119
80
  }
120
81
  }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Copyright 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @providesModule DOMLazyTree
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var setTextContent = require('./setTextContent');
15
+
16
+ /**
17
+ * In IE (8-11) and Edge, appending nodes with no children is dramatically
18
+ * faster than appending a full subtree, so we essentially queue up the
19
+ * .appendChild calls here and apply them so each node is added to its parent
20
+ * before any children are added.
21
+ *
22
+ * In other browsers, doing so is slower or neutral compared to the other order
23
+ * (in Firefox, twice as slow) so we only do this inversion in IE.
24
+ *
25
+ * See https://github.com/spicyj/innerhtml-vs-createelement-vs-clonenode.
26
+ */
27
+ var enableLazy = typeof document !== 'undefined' && typeof document.documentMode === 'number' || typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string' && /\bEdge\/\d/.test(navigator.userAgent);
28
+
29
+ function insertTreeChildren(tree) {
30
+ if (!enableLazy) {
31
+ return;
32
+ }
33
+ var node = tree.node;
34
+ var children = tree.children;
35
+ if (children.length) {
36
+ for (var i = 0; i < children.length; i++) {
37
+ insertTreeBefore(node, children[i], null);
38
+ }
39
+ } else if (tree.html != null) {
40
+ node.innerHTML = tree.html;
41
+ } else if (tree.text != null) {
42
+ setTextContent(node, tree.text);
43
+ }
44
+ }
45
+
46
+ function insertTreeBefore(parentNode, tree, referenceNode) {
47
+ parentNode.insertBefore(tree.node, referenceNode);
48
+ insertTreeChildren(tree);
49
+ }
50
+
51
+ function replaceChildWithTree(oldNode, newTree) {
52
+ oldNode.parentNode.replaceChild(newTree.node, oldNode);
53
+ insertTreeChildren(newTree);
54
+ }
55
+
56
+ function queueChild(parentTree, childTree) {
57
+ if (enableLazy) {
58
+ parentTree.children.push(childTree);
59
+ } else {
60
+ parentTree.node.appendChild(childTree.node);
61
+ }
62
+ }
63
+
64
+ function queueHTML(tree, html) {
65
+ if (enableLazy) {
66
+ tree.html = html;
67
+ } else {
68
+ tree.node.innerHTML = html;
69
+ }
70
+ }
71
+
72
+ function queueText(tree, text) {
73
+ if (enableLazy) {
74
+ tree.text = text;
75
+ } else {
76
+ setTextContent(tree.node, text);
77
+ }
78
+ }
79
+
80
+ function DOMLazyTree(node) {
81
+ return {
82
+ node: node,
83
+ children: [],
84
+ html: null,
85
+ text: null
86
+ };
87
+ }
88
+
89
+ DOMLazyTree.insertTreeBefore = insertTreeBefore;
90
+ DOMLazyTree.replaceChildWithTree = replaceChildWithTree;
91
+ DOMLazyTree.queueChild = queueChild;
92
+ DOMLazyTree.queueHTML = queueHTML;
93
+ DOMLazyTree.queueText = queueText;
94
+
95
+ module.exports = DOMLazyTree;
@@ -1,23 +1,20 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
6
6
  * LICENSE file in the root directory of this source tree. An additional grant
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
- * @providesModule ClientReactRootIndex
10
- * @typechecks
9
+ * @providesModule DOMNamespaces
11
10
  */
12
11
 
13
12
  'use strict';
14
13
 
15
- var nextReactRootIndex = 0;
16
-
17
- var ClientReactRootIndex = {
18
- createReactRootIndex: function () {
19
- return nextReactRootIndex++;
20
- }
14
+ var DOMNamespaces = {
15
+ html: 'http://www.w3.org/1999/xhtml',
16
+ mathml: 'http://www.w3.org/1998/Math/MathML',
17
+ svg: 'http://www.w3.org/2000/svg'
21
18
  };
22
19
 
23
- module.exports = ClientReactRootIndex;
20
+ module.exports = DOMNamespaces;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,7 +7,6 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule DOMProperty
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
@@ -126,6 +125,8 @@ var DOMPropertyInjection = {
126
125
  };
127
126
  var defaultValueCache = {};
128
127
 
128
+ var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
129
+
129
130
  /**
130
131
  * DOMProperty exports lookup objects that can be used like functions:
131
132
  *
@@ -142,6 +143,10 @@ var defaultValueCache = {};
142
143
  var DOMProperty = {
143
144
 
144
145
  ID_ATTRIBUTE_NAME: 'data-reactid',
146
+ ROOT_ATTRIBUTE_NAME: 'data-reactroot',
147
+
148
+ ATTRIBUTE_NAME_START_CHAR: ATTRIBUTE_NAME_START_CHAR,
149
+ ATTRIBUTE_NAME_CHAR: ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\uB7\\u0300-\\u036F\\u203F-\\u2040',
145
150
 
146
151
  /**
147
152
  * Map from property "standard name" to an object with info about how to set
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,19 +7,18 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule DOMPropertyOperations
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
14
13
 
15
14
  var DOMProperty = require('./DOMProperty');
15
+ var ReactDOMInstrumentation = require('./ReactDOMInstrumentation');
16
16
  var ReactPerf = require('./ReactPerf');
17
17
 
18
18
  var quoteAttributeValueForBrowser = require('./quoteAttributeValueForBrowser');
19
19
  var warning = require('fbjs/lib/warning');
20
20
 
21
- // Simplified subset
22
- var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][\w\.\-]*$/;
21
+ var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
23
22
  var illegalAttributeNameCache = {};
24
23
  var validatedAttributeNameCache = {};
25
24
 
@@ -43,32 +42,6 @@ function shouldIgnoreValue(propertyInfo, value) {
43
42
  return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
44
43
  }
45
44
 
46
- if (process.env.NODE_ENV !== 'production') {
47
- var reactProps = {
48
- children: true,
49
- dangerouslySetInnerHTML: true,
50
- key: true,
51
- ref: true
52
- };
53
- var warnedProperties = {};
54
-
55
- var warnUnknownProperty = function (name) {
56
- if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
57
- return;
58
- }
59
-
60
- warnedProperties[name] = true;
61
- var lowerCasedName = name.toLowerCase();
62
-
63
- // data-* attributes should be lowercase; suggest the lowercase version
64
- var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
65
-
66
- // For now, only warn when we have a suggested correction. This prevents
67
- // logging too much when using transferPropsTo.
68
- process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
69
- };
70
- }
71
-
72
45
  /**
73
46
  * Operations for dealing with DOM properties.
74
47
  */
@@ -88,6 +61,14 @@ var DOMPropertyOperations = {
88
61
  node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
89
62
  },
90
63
 
64
+ createMarkupForRoot: function () {
65
+ return DOMProperty.ROOT_ATTRIBUTE_NAME + '=""';
66
+ },
67
+
68
+ setAttributeForRoot: function (node) {
69
+ node.setAttribute(DOMProperty.ROOT_ATTRIBUTE_NAME, '');
70
+ },
71
+
91
72
  /**
92
73
  * Creates markup for a property.
93
74
  *
@@ -96,6 +77,9 @@ var DOMPropertyOperations = {
96
77
  * @return {?string} Markup string, or null if the property was invalid.
97
78
  */
98
79
  createMarkupForProperty: function (name, value) {
80
+ if (process.env.NODE_ENV !== 'production') {
81
+ ReactDOMInstrumentation.debugTool.onCreateMarkupForProperty(name, value);
82
+ }
99
83
  var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
100
84
  if (propertyInfo) {
101
85
  if (shouldIgnoreValue(propertyInfo, value)) {
@@ -111,8 +95,6 @@ var DOMPropertyOperations = {
111
95
  return '';
112
96
  }
113
97
  return name + '=' + quoteAttributeValueForBrowser(value);
114
- } else if (process.env.NODE_ENV !== 'production') {
115
- warnUnknownProperty(name);
116
98
  }
117
99
  return null;
118
100
  },
@@ -131,6 +113,31 @@ var DOMPropertyOperations = {
131
113
  return name + '=' + quoteAttributeValueForBrowser(value);
132
114
  },
133
115
 
116
+ /**
117
+ * Creates markup for an SVG property.
118
+ *
119
+ * @param {string} name
120
+ * @param {*} value
121
+ * @return {string} Markup string, or empty string if the property was invalid.
122
+ */
123
+ createMarkupForSVGAttribute: function (name, value) {
124
+ if (process.env.NODE_ENV !== 'production') {
125
+ ReactDOMInstrumentation.debugTool.onCreateMarkupForSVGAttribute(name, value);
126
+ }
127
+ if (!isAttributeNameSafe(name) || value == null) {
128
+ return '';
129
+ }
130
+ var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
131
+ if (propertyInfo) {
132
+ // Migration path for deprecated camelCase aliases for SVG attributes
133
+ var attributeName = propertyInfo.attributeName;
134
+
135
+ return attributeName + '=' + quoteAttributeValueForBrowser(value);
136
+ } else {
137
+ return name + '=' + quoteAttributeValueForBrowser(value);
138
+ }
139
+ },
140
+
134
141
  /**
135
142
  * Sets the value for a property on a node.
136
143
  *
@@ -139,6 +146,9 @@ var DOMPropertyOperations = {
139
146
  * @param {*} value
140
147
  */
141
148
  setValueForProperty: function (node, name, value) {
149
+ if (process.env.NODE_ENV !== 'production') {
150
+ ReactDOMInstrumentation.debugTool.onSetValueForProperty(node, name, value);
151
+ }
142
152
  var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
143
153
  if (propertyInfo) {
144
154
  var mutationMethod = propertyInfo.mutationMethod;
@@ -170,8 +180,6 @@ var DOMPropertyOperations = {
170
180
  }
171
181
  } else if (DOMProperty.isCustomAttribute(name)) {
172
182
  DOMPropertyOperations.setValueForAttribute(node, name, value);
173
- } else if (process.env.NODE_ENV !== 'production') {
174
- warnUnknownProperty(name);
175
183
  }
176
184
  },
177
185
 
@@ -186,6 +194,18 @@ var DOMPropertyOperations = {
186
194
  }
187
195
  },
188
196
 
197
+ setValueForSVGAttribute: function (node, name, value) {
198
+ if (process.env.NODE_ENV !== 'production') {
199
+ ReactDOMInstrumentation.debugTool.onSetValueForSVGAttribute(node, name, value);
200
+ }
201
+ if (DOMProperty.properties.hasOwnProperty(name)) {
202
+ // Migration path for deprecated camelCase aliases for SVG attributes
203
+ DOMPropertyOperations.setValueForProperty(node, name, value);
204
+ } else {
205
+ DOMPropertyOperations.setValueForAttribute(node, name, value);
206
+ }
207
+ },
208
+
189
209
  /**
190
210
  * Deletes the value for a property on a node.
191
211
  *
@@ -193,6 +213,9 @@ var DOMPropertyOperations = {
193
213
  * @param {string} name
194
214
  */
195
215
  deleteValueForProperty: function (node, name) {
216
+ if (process.env.NODE_ENV !== 'production') {
217
+ ReactDOMInstrumentation.debugTool.onDeleteValueForProperty(node, name);
218
+ }
196
219
  var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
197
220
  if (propertyInfo) {
198
221
  var mutationMethod = propertyInfo.mutationMethod;
@@ -209,8 +232,15 @@ var DOMPropertyOperations = {
209
232
  }
210
233
  } else if (DOMProperty.isCustomAttribute(name)) {
211
234
  node.removeAttribute(name);
212
- } else if (process.env.NODE_ENV !== 'production') {
213
- warnUnknownProperty(name);
235
+ }
236
+ },
237
+
238
+ deleteValueForSVGAttribute: function (node, name) {
239
+ var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
240
+ if (propertyInfo) {
241
+ DOMPropertyOperations.deleteValueForProperty(node, name);
242
+ } else {
243
+ node.removeAttribute(name);
214
244
  }
215
245
  }
216
246