react 15.3.2-rc.1 → 15.4.0-rc.3

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 (209) hide show
  1. package/dist/react-with-addons.js +3863 -21388
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2639 -19486
  4. package/dist/react.min.js +2 -6
  5. package/lib/KeyEscapeUtils.js +0 -1
  6. package/lib/LinkedStateMixin.js +1 -3
  7. package/lib/PooledClass.js +3 -1
  8. package/lib/React.js +0 -1
  9. package/lib/ReactAddonsDOMDependencies.js +35 -0
  10. package/lib/ReactAddonsDOMDependenciesUMDShim.js +31 -0
  11. package/lib/ReactCSSTransitionGroup.js +60 -43
  12. package/lib/ReactCSSTransitionGroupChild.js +2 -3
  13. package/lib/ReactChildren.js +0 -1
  14. package/lib/ReactClass.js +38 -54
  15. package/lib/ReactComponent.js +0 -1
  16. package/lib/ReactComponentTreeDevtool.js +0 -1
  17. package/lib/ReactComponentTreeHook.js +84 -101
  18. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +4 -7
  19. package/lib/ReactComponentWithPureRenderMixin.js +0 -1
  20. package/lib/ReactCurrentOwner.js +1 -2
  21. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +5 -4
  22. package/lib/ReactDOMFactories.js +0 -1
  23. package/lib/ReactElement.js +6 -14
  24. package/lib/ReactElementSymbol.js +19 -0
  25. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +3 -9
  26. package/lib/ReactElementValidator.js +1 -3
  27. package/lib/ReactFragment.js +0 -1
  28. package/lib/ReactLink.js +0 -1
  29. package/lib/ReactNoopUpdateQueue.js +0 -1
  30. package/lib/ReactPropTypeLocationNames.js +1 -1
  31. package/lib/ReactPropTypeLocations.js +2 -12
  32. package/lib/ReactPropTypes.js +5 -3
  33. package/lib/ReactPropTypesSecret.js +1 -1
  34. package/lib/ReactPureComponent.js +0 -1
  35. package/lib/ReactStateSetters.js +0 -1
  36. package/lib/ReactTransitionChildMapping.js +0 -1
  37. package/lib/ReactTransitionEvents.js +1 -2
  38. package/lib/ReactTransitionGroup.js +145 -142
  39. package/lib/ReactUMDEntry.js +11 -6
  40. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +3 -6
  41. package/lib/ReactVersion.js +1 -2
  42. package/lib/ReactWithAddons.js +15 -3
  43. package/lib/ReactWithAddonsUMDEntry.js +11 -6
  44. package/lib/canDefineProperty.js +2 -1
  45. package/lib/checkReactTypeSpec.js +0 -1
  46. package/lib/deprecated.js +0 -1
  47. package/lib/flattenChildren.js +0 -1
  48. package/lib/getIteratorFn.js +0 -1
  49. package/lib/onlyChild.js +0 -1
  50. package/lib/reactProdInvariant.js +0 -1
  51. package/lib/sliceChildren.js +0 -1
  52. package/lib/traverseAllChildren.js +11 -3
  53. package/lib/update.js +6 -8
  54. package/package.json +1 -1
  55. package/lib/AutoFocusUtils.js +0 -24
  56. package/lib/BeforeInputEventPlugin.js +0 -390
  57. package/lib/CSSProperty.js +0 -148
  58. package/lib/CSSPropertyOperations.js +0 -205
  59. package/lib/CallbackQueue.js +0 -106
  60. package/lib/ChangeEventPlugin.js +0 -325
  61. package/lib/DOMChildrenOperations.js +0 -194
  62. package/lib/DOMLazyTree.js +0 -118
  63. package/lib/DOMProperty.js +0 -206
  64. package/lib/DOMPropertyOperations.js +0 -221
  65. package/lib/Danger.js +0 -48
  66. package/lib/DefaultEventPluginOrder.js +0 -27
  67. package/lib/DisabledInputUtils.js +0 -50
  68. package/lib/EnterLeaveEventPlugin.js +0 -105
  69. package/lib/EventConstants.js +0 -97
  70. package/lib/EventPluginHub.js +0 -251
  71. package/lib/EventPluginRegistry.js +0 -247
  72. package/lib/EventPluginUtils.js +0 -229
  73. package/lib/EventPropagators.js +0 -137
  74. package/lib/FallbackCompositionState.js +0 -95
  75. package/lib/HTMLDOMPropertyConfig.js +0 -212
  76. package/lib/LinkedValueUtils.js +0 -136
  77. package/lib/NativeMethodsMixin.js +0 -167
  78. package/lib/ReactBrowserEventEmitter.js +0 -330
  79. package/lib/ReactChildReconciler.js +0 -154
  80. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  81. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  82. package/lib/ReactComponentEnvironment.js +0 -45
  83. package/lib/ReactComponentTreeTestUtils.js +0 -87
  84. package/lib/ReactCompositeComponent.js +0 -904
  85. package/lib/ReactDOM.js +0 -110
  86. package/lib/ReactDOMButton.js +0 -24
  87. package/lib/ReactDOMComponent.js +0 -1006
  88. package/lib/ReactDOMComponentTree.js +0 -188
  89. package/lib/ReactDOMContainerInfo.js +0 -33
  90. package/lib/ReactDOMEmptyComponent.js +0 -60
  91. package/lib/ReactDOMFiber.js +0 -76
  92. package/lib/ReactDOMIDOperations.js +0 -34
  93. package/lib/ReactDOMInput.js +0 -269
  94. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  95. package/lib/ReactDOMOption.js +0 -123
  96. package/lib/ReactDOMSelect.js +0 -201
  97. package/lib/ReactDOMSelection.js +0 -212
  98. package/lib/ReactDOMServer.js +0 -26
  99. package/lib/ReactDOMTextComponent.js +0 -164
  100. package/lib/ReactDOMTextarea.js +0 -155
  101. package/lib/ReactDOMTreeTraversal.js +0 -136
  102. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  103. package/lib/ReactDebugTool.js +0 -301
  104. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  105. package/lib/ReactDefaultInjection.js +0 -84
  106. package/lib/ReactEmptyComponent.js +0 -30
  107. package/lib/ReactErrorUtils.js +0 -76
  108. package/lib/ReactEventEmitterMixin.js +0 -33
  109. package/lib/ReactEventListener.js +0 -157
  110. package/lib/ReactFeatureFlags.js +0 -22
  111. package/lib/ReactHostComponent.js +0 -76
  112. package/lib/ReactHostOperationHistoryHook.js +0 -37
  113. package/lib/ReactInjection.js +0 -36
  114. package/lib/ReactInputSelection.js +0 -124
  115. package/lib/ReactInstanceHandles.js +0 -302
  116. package/lib/ReactInstanceMap.js +0 -48
  117. package/lib/ReactInstrumentation.js +0 -21
  118. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  119. package/lib/ReactMarkupChecksum.js +0 -50
  120. package/lib/ReactMount.js +0 -534
  121. package/lib/ReactMultiChild.js +0 -451
  122. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  123. package/lib/ReactNative.js +0 -71
  124. package/lib/ReactNativeAttributePayload.js +0 -371
  125. package/lib/ReactNativeBaseComponent.js +0 -198
  126. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  127. package/lib/ReactNativeComponentEnvironment.js +0 -31
  128. package/lib/ReactNativeComponentTree.js +0 -68
  129. package/lib/ReactNativeContainerInfo.js +0 -21
  130. package/lib/ReactNativeDOMIDOperations.js +0 -79
  131. package/lib/ReactNativeDefaultInjection.js +0 -101
  132. package/lib/ReactNativeEventEmitter.js +0 -191
  133. package/lib/ReactNativeEventPluginOrder.js +0 -16
  134. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  135. package/lib/ReactNativeMount.js +0 -193
  136. package/lib/ReactNativePropRegistry.js +0 -52
  137. package/lib/ReactNativeReconcileTransaction.js +0 -129
  138. package/lib/ReactNativeTagHandles.js +0 -56
  139. package/lib/ReactNativeTextComponent.js +0 -71
  140. package/lib/ReactNativeTreeTraversal.js +0 -127
  141. package/lib/ReactNodeTypes.js +0 -40
  142. package/lib/ReactNoop.js +0 -173
  143. package/lib/ReactOwner.js +0 -94
  144. package/lib/ReactPerf.js +0 -494
  145. package/lib/ReactReconcileTransaction.js +0 -178
  146. package/lib/ReactReconciler.js +0 -168
  147. package/lib/ReactRef.js +0 -80
  148. package/lib/ReactServerBatchingStrategy.js +0 -22
  149. package/lib/ReactServerRendering.js +0 -90
  150. package/lib/ReactServerRenderingTransaction.js +0 -90
  151. package/lib/ReactServerUpdateQueue.js +0 -141
  152. package/lib/ReactSimpleEmptyComponent.js +0 -37
  153. package/lib/ReactTestMount.js +0 -126
  154. package/lib/ReactTestReconcileTransaction.js +0 -121
  155. package/lib/ReactTestRenderer.js +0 -144
  156. package/lib/ReactTestUtils.js +0 -518
  157. package/lib/ReactUpdateQueue.js +0 -226
  158. package/lib/ReactUpdates.js +0 -251
  159. package/lib/ResponderEventPlugin.js +0 -510
  160. package/lib/ResponderSyntheticEvent.js +0 -39
  161. package/lib/ResponderTouchHistoryStore.js +0 -184
  162. package/lib/SVGDOMPropertyConfig.js +0 -302
  163. package/lib/SelectEventPlugin.js +0 -196
  164. package/lib/SimpleEventPlugin.js +0 -635
  165. package/lib/SyntheticAnimationEvent.js +0 -39
  166. package/lib/SyntheticClipboardEvent.js +0 -38
  167. package/lib/SyntheticCompositionEvent.js +0 -36
  168. package/lib/SyntheticDragEvent.js +0 -36
  169. package/lib/SyntheticEvent.js +0 -268
  170. package/lib/SyntheticFocusEvent.js +0 -36
  171. package/lib/SyntheticInputEvent.js +0 -37
  172. package/lib/SyntheticKeyboardEvent.js +0 -84
  173. package/lib/SyntheticMouseEvent.js +0 -72
  174. package/lib/SyntheticTouchEvent.js +0 -45
  175. package/lib/SyntheticTransitionEvent.js +0 -39
  176. package/lib/SyntheticUIEvent.js +0 -59
  177. package/lib/SyntheticWheelEvent.js +0 -54
  178. package/lib/TapEventPlugin.js +0 -110
  179. package/lib/TouchHistoryMath.js +0 -99
  180. package/lib/Transaction.js +0 -233
  181. package/lib/ViewportMetrics.js +0 -27
  182. package/lib/accumulate.js +0 -46
  183. package/lib/accumulateInto.js +0 -58
  184. package/lib/adler32.js +0 -44
  185. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  186. package/lib/createReactNativeComponentClass.js +0 -42
  187. package/lib/dangerousStyleValue.js +0 -79
  188. package/lib/escapeTextContentForBrowser.js +0 -123
  189. package/lib/findDOMNode.js +0 -60
  190. package/lib/findNodeHandle.js +0 -91
  191. package/lib/forEachAccumulated.js +0 -31
  192. package/lib/getEventCharCode.js +0 -50
  193. package/lib/getEventKey.js +0 -102
  194. package/lib/getEventModifierState.js +0 -43
  195. package/lib/getEventTarget.js +0 -35
  196. package/lib/getHostComponentFromComposite.js +0 -30
  197. package/lib/getNodeForCharacterOffset.js +0 -74
  198. package/lib/getTestDocument.js +0 -21
  199. package/lib/getTextContentAccessor.js +0 -33
  200. package/lib/getVendorPrefixedEventName.js +0 -101
  201. package/lib/instantiateReactComponent.js +0 -119
  202. package/lib/isEventSupported.js +0 -60
  203. package/lib/isTextInputElement.js +0 -51
  204. package/lib/quoteAttributeValueForBrowser.js +0 -26
  205. package/lib/reactComponentExpect.js +0 -217
  206. package/lib/setInnerHTML.js +0 -98
  207. package/lib/setTextContent.js +0 -48
  208. package/lib/shouldUpdateReactComponent.js +0 -42
  209. package/lib/validateDOMNesting.js +0 -382
@@ -1,118 +0,0 @@
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 DOMNamespaces = require('./DOMNamespaces');
15
- var setInnerHTML = require('./setInnerHTML');
16
-
17
- var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction');
18
- var setTextContent = require('./setTextContent');
19
-
20
- var ELEMENT_NODE_TYPE = 1;
21
- var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
22
-
23
- /**
24
- * In IE (8-11) and Edge, appending nodes with no children is dramatically
25
- * faster than appending a full subtree, so we essentially queue up the
26
- * .appendChild calls here and apply them so each node is added to its parent
27
- * before any children are added.
28
- *
29
- * In other browsers, doing so is slower or neutral compared to the other order
30
- * (in Firefox, twice as slow) so we only do this inversion in IE.
31
- *
32
- * See https://github.com/spicyj/innerhtml-vs-createelement-vs-clonenode.
33
- */
34
- var enableLazy = typeof document !== 'undefined' && typeof document.documentMode === 'number' || typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string' && /\bEdge\/\d/.test(navigator.userAgent);
35
-
36
- function insertTreeChildren(tree) {
37
- if (!enableLazy) {
38
- return;
39
- }
40
- var node = tree.node;
41
- var children = tree.children;
42
- if (children.length) {
43
- for (var i = 0; i < children.length; i++) {
44
- insertTreeBefore(node, children[i], null);
45
- }
46
- } else if (tree.html != null) {
47
- setInnerHTML(node, tree.html);
48
- } else if (tree.text != null) {
49
- setTextContent(node, tree.text);
50
- }
51
- }
52
-
53
- var insertTreeBefore = createMicrosoftUnsafeLocalFunction(function (parentNode, tree, referenceNode) {
54
- // DocumentFragments aren't actually part of the DOM after insertion so
55
- // appending children won't update the DOM. We need to ensure the fragment
56
- // is properly populated first, breaking out of our lazy approach for just
57
- // this level. Also, some <object> plugins (like Flash Player) will read
58
- // <param> nodes immediately upon insertion into the DOM, so <object>
59
- // must also be populated prior to insertion into the DOM.
60
- if (tree.node.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE || tree.node.nodeType === ELEMENT_NODE_TYPE && tree.node.nodeName.toLowerCase() === 'object' && (tree.node.namespaceURI == null || tree.node.namespaceURI === DOMNamespaces.html)) {
61
- insertTreeChildren(tree);
62
- parentNode.insertBefore(tree.node, referenceNode);
63
- } else {
64
- parentNode.insertBefore(tree.node, referenceNode);
65
- insertTreeChildren(tree);
66
- }
67
- });
68
-
69
- function replaceChildWithTree(oldNode, newTree) {
70
- oldNode.parentNode.replaceChild(newTree.node, oldNode);
71
- insertTreeChildren(newTree);
72
- }
73
-
74
- function queueChild(parentTree, childTree) {
75
- if (enableLazy) {
76
- parentTree.children.push(childTree);
77
- } else {
78
- parentTree.node.appendChild(childTree.node);
79
- }
80
- }
81
-
82
- function queueHTML(tree, html) {
83
- if (enableLazy) {
84
- tree.html = html;
85
- } else {
86
- setInnerHTML(tree.node, html);
87
- }
88
- }
89
-
90
- function queueText(tree, text) {
91
- if (enableLazy) {
92
- tree.text = text;
93
- } else {
94
- setTextContent(tree.node, text);
95
- }
96
- }
97
-
98
- function toString() {
99
- return this.node.nodeName;
100
- }
101
-
102
- function DOMLazyTree(node) {
103
- return {
104
- node: node,
105
- children: [],
106
- html: null,
107
- text: null,
108
- toString: toString
109
- };
110
- }
111
-
112
- DOMLazyTree.insertTreeBefore = insertTreeBefore;
113
- DOMLazyTree.replaceChildWithTree = replaceChildWithTree;
114
- DOMLazyTree.queueChild = queueChild;
115
- DOMLazyTree.queueHTML = queueHTML;
116
- DOMLazyTree.queueText = queueText;
117
-
118
- module.exports = DOMLazyTree;
@@ -1,206 +0,0 @@
1
- /**
2
- * Copyright 2013-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 DOMProperty
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant');
15
-
16
- var invariant = require('fbjs/lib/invariant');
17
-
18
- function checkMask(value, bitmask) {
19
- return (value & bitmask) === bitmask;
20
- }
21
-
22
- var DOMPropertyInjection = {
23
- /**
24
- * Mapping from normalized, camelcased property names to a configuration that
25
- * specifies how the associated DOM property should be accessed or rendered.
26
- */
27
- MUST_USE_PROPERTY: 0x1,
28
- HAS_BOOLEAN_VALUE: 0x4,
29
- HAS_NUMERIC_VALUE: 0x8,
30
- HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8,
31
- HAS_OVERLOADED_BOOLEAN_VALUE: 0x20,
32
-
33
- /**
34
- * Inject some specialized knowledge about the DOM. This takes a config object
35
- * with the following properties:
36
- *
37
- * isCustomAttribute: function that given an attribute name will return true
38
- * if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
39
- * attributes where it's impossible to enumerate all of the possible
40
- * attribute names,
41
- *
42
- * Properties: object mapping DOM property name to one of the
43
- * DOMPropertyInjection constants or null. If your attribute isn't in here,
44
- * it won't get written to the DOM.
45
- *
46
- * DOMAttributeNames: object mapping React attribute name to the DOM
47
- * attribute name. Attribute names not specified use the **lowercase**
48
- * normalized name.
49
- *
50
- * DOMAttributeNamespaces: object mapping React attribute name to the DOM
51
- * attribute namespace URL. (Attribute names not specified use no namespace.)
52
- *
53
- * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
54
- * Property names not specified use the normalized name.
55
- *
56
- * DOMMutationMethods: Properties that require special mutation methods. If
57
- * `value` is undefined, the mutation method should unset the property.
58
- *
59
- * @param {object} domPropertyConfig the config as described above.
60
- */
61
- injectDOMPropertyConfig: function (domPropertyConfig) {
62
- var Injection = DOMPropertyInjection;
63
- var Properties = domPropertyConfig.Properties || {};
64
- var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {};
65
- var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
66
- var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
67
- var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
68
-
69
- if (domPropertyConfig.isCustomAttribute) {
70
- DOMProperty._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute);
71
- }
72
-
73
- for (var propName in Properties) {
74
- !!DOMProperty.properties.hasOwnProperty(propName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property \'%s\' which has already been injected. You may be accidentally injecting the same DOM property config twice, or you may be injecting two configs that have conflicting property names.', propName) : _prodInvariant('48', propName) : void 0;
75
-
76
- var lowerCased = propName.toLowerCase();
77
- var propConfig = Properties[propName];
78
-
79
- var propertyInfo = {
80
- attributeName: lowerCased,
81
- attributeNamespace: null,
82
- propertyName: propName,
83
- mutationMethod: null,
84
-
85
- mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
86
- hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
87
- hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE),
88
- hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE),
89
- hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE)
90
- };
91
- !(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or numeric value, but not a combination: %s', propName) : _prodInvariant('50', propName) : void 0;
92
-
93
- if (process.env.NODE_ENV !== 'production') {
94
- DOMProperty.getPossibleStandardName[lowerCased] = propName;
95
- }
96
-
97
- if (DOMAttributeNames.hasOwnProperty(propName)) {
98
- var attributeName = DOMAttributeNames[propName];
99
- propertyInfo.attributeName = attributeName;
100
- if (process.env.NODE_ENV !== 'production') {
101
- DOMProperty.getPossibleStandardName[attributeName] = propName;
102
- }
103
- }
104
-
105
- if (DOMAttributeNamespaces.hasOwnProperty(propName)) {
106
- propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName];
107
- }
108
-
109
- if (DOMPropertyNames.hasOwnProperty(propName)) {
110
- propertyInfo.propertyName = DOMPropertyNames[propName];
111
- }
112
-
113
- if (DOMMutationMethods.hasOwnProperty(propName)) {
114
- propertyInfo.mutationMethod = DOMMutationMethods[propName];
115
- }
116
-
117
- DOMProperty.properties[propName] = propertyInfo;
118
- }
119
- }
120
- };
121
-
122
- /* eslint-disable max-len */
123
- 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';
124
- /* eslint-enable max-len */
125
-
126
- /**
127
- * DOMProperty exports lookup objects that can be used like functions:
128
- *
129
- * > DOMProperty.isValid['id']
130
- * true
131
- * > DOMProperty.isValid['foobar']
132
- * undefined
133
- *
134
- * Although this may be confusing, it performs better in general.
135
- *
136
- * @see http://jsperf.com/key-exists
137
- * @see http://jsperf.com/key-missing
138
- */
139
- var DOMProperty = {
140
-
141
- ID_ATTRIBUTE_NAME: 'data-reactid',
142
- ROOT_ATTRIBUTE_NAME: 'data-reactroot',
143
-
144
- ATTRIBUTE_NAME_START_CHAR: ATTRIBUTE_NAME_START_CHAR,
145
- ATTRIBUTE_NAME_CHAR: ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040',
146
-
147
- /**
148
- * Map from property "standard name" to an object with info about how to set
149
- * the property in the DOM. Each object contains:
150
- *
151
- * attributeName:
152
- * Used when rendering markup or with `*Attribute()`.
153
- * attributeNamespace
154
- * propertyName:
155
- * Used on DOM node instances. (This includes properties that mutate due to
156
- * external factors.)
157
- * mutationMethod:
158
- * If non-null, used instead of the property or `setAttribute()` after
159
- * initial render.
160
- * mustUseProperty:
161
- * Whether the property must be accessed and mutated as an object property.
162
- * hasBooleanValue:
163
- * Whether the property should be removed when set to a falsey value.
164
- * hasNumericValue:
165
- * Whether the property must be numeric or parse as a numeric and should be
166
- * removed when set to a falsey value.
167
- * hasPositiveNumericValue:
168
- * Whether the property must be positive numeric or parse as a positive
169
- * numeric and should be removed when set to a falsey value.
170
- * hasOverloadedBooleanValue:
171
- * Whether the property can be used as a flag as well as with a value.
172
- * Removed when strictly equal to false; present without a value when
173
- * strictly equal to true; present with a value otherwise.
174
- */
175
- properties: {},
176
-
177
- /**
178
- * Mapping from lowercase property names to the properly cased version, used
179
- * to warn in the case of missing properties. Available only in __DEV__.
180
- * @type {Object}
181
- */
182
- getPossibleStandardName: process.env.NODE_ENV !== 'production' ? {} : null,
183
-
184
- /**
185
- * All of the isCustomAttribute() functions that have been injected.
186
- */
187
- _isCustomAttributeFunctions: [],
188
-
189
- /**
190
- * Checks whether a property name is a custom attribute.
191
- * @method
192
- */
193
- isCustomAttribute: function (attributeName) {
194
- for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
195
- var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
196
- if (isCustomAttributeFn(attributeName)) {
197
- return true;
198
- }
199
- }
200
- return false;
201
- },
202
-
203
- injection: DOMPropertyInjection
204
- };
205
-
206
- module.exports = DOMProperty;
@@ -1,221 +0,0 @@
1
- /**
2
- * Copyright 2013-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 DOMPropertyOperations
10
- */
11
-
12
- 'use strict';
13
-
14
- var DOMProperty = require('./DOMProperty');
15
- var ReactDOMComponentTree = require('./ReactDOMComponentTree');
16
- var ReactInstrumentation = require('./ReactInstrumentation');
17
-
18
- var quoteAttributeValueForBrowser = require('./quoteAttributeValueForBrowser');
19
- var warning = require('fbjs/lib/warning');
20
-
21
- var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
22
- var illegalAttributeNameCache = {};
23
- var validatedAttributeNameCache = {};
24
-
25
- function isAttributeNameSafe(attributeName) {
26
- if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
27
- return true;
28
- }
29
- if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
30
- return false;
31
- }
32
- if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
33
- validatedAttributeNameCache[attributeName] = true;
34
- return true;
35
- }
36
- illegalAttributeNameCache[attributeName] = true;
37
- process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : void 0;
38
- return false;
39
- }
40
-
41
- function shouldIgnoreValue(propertyInfo, value) {
42
- return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
43
- }
44
-
45
- /**
46
- * Operations for dealing with DOM properties.
47
- */
48
- var DOMPropertyOperations = {
49
-
50
- /**
51
- * Creates markup for the ID property.
52
- *
53
- * @param {string} id Unescaped ID.
54
- * @return {string} Markup string.
55
- */
56
- createMarkupForID: function (id) {
57
- return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
58
- },
59
-
60
- setAttributeForID: function (node, id) {
61
- node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
62
- },
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
-
72
- /**
73
- * Creates markup for a property.
74
- *
75
- * @param {string} name
76
- * @param {*} value
77
- * @return {?string} Markup string, or null if the property was invalid.
78
- */
79
- createMarkupForProperty: function (name, value) {
80
- var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
81
- if (propertyInfo) {
82
- if (shouldIgnoreValue(propertyInfo, value)) {
83
- return '';
84
- }
85
- var attributeName = propertyInfo.attributeName;
86
- if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
87
- return attributeName + '=""';
88
- }
89
- return attributeName + '=' + quoteAttributeValueForBrowser(value);
90
- } else if (DOMProperty.isCustomAttribute(name)) {
91
- if (value == null) {
92
- return '';
93
- }
94
- return name + '=' + quoteAttributeValueForBrowser(value);
95
- }
96
- return null;
97
- },
98
-
99
- /**
100
- * Creates markup for a custom property.
101
- *
102
- * @param {string} name
103
- * @param {*} value
104
- * @return {string} Markup string, or empty string if the property was invalid.
105
- */
106
- createMarkupForCustomAttribute: function (name, value) {
107
- if (!isAttributeNameSafe(name) || value == null) {
108
- return '';
109
- }
110
- return name + '=' + quoteAttributeValueForBrowser(value);
111
- },
112
-
113
- /**
114
- * Sets the value for a property on a node.
115
- *
116
- * @param {DOMElement} node
117
- * @param {string} name
118
- * @param {*} value
119
- */
120
- setValueForProperty: function (node, name, value) {
121
- var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
122
- if (propertyInfo) {
123
- var mutationMethod = propertyInfo.mutationMethod;
124
- if (mutationMethod) {
125
- mutationMethod(node, value);
126
- } else if (shouldIgnoreValue(propertyInfo, value)) {
127
- this.deleteValueForProperty(node, name);
128
- return;
129
- } else if (propertyInfo.mustUseProperty) {
130
- // Contrary to `setAttribute`, object properties are properly
131
- // `toString`ed by IE8/9.
132
- node[propertyInfo.propertyName] = value;
133
- } else {
134
- var attributeName = propertyInfo.attributeName;
135
- var namespace = propertyInfo.attributeNamespace;
136
- // `setAttribute` with objects becomes only `[object]` in IE8/9,
137
- // ('' + value) makes it output the correct toString()-value.
138
- if (namespace) {
139
- node.setAttributeNS(namespace, attributeName, '' + value);
140
- } else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
141
- node.setAttribute(attributeName, '');
142
- } else {
143
- node.setAttribute(attributeName, '' + value);
144
- }
145
- }
146
- } else if (DOMProperty.isCustomAttribute(name)) {
147
- DOMPropertyOperations.setValueForAttribute(node, name, value);
148
- return;
149
- }
150
-
151
- if (process.env.NODE_ENV !== 'production') {
152
- var payload = {};
153
- payload[name] = value;
154
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'update attribute', payload);
155
- }
156
- },
157
-
158
- setValueForAttribute: function (node, name, value) {
159
- if (!isAttributeNameSafe(name)) {
160
- return;
161
- }
162
- if (value == null) {
163
- node.removeAttribute(name);
164
- } else {
165
- node.setAttribute(name, '' + value);
166
- }
167
-
168
- if (process.env.NODE_ENV !== 'production') {
169
- var payload = {};
170
- payload[name] = value;
171
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'update attribute', payload);
172
- }
173
- },
174
-
175
- /**
176
- * Deletes an attributes from a node.
177
- *
178
- * @param {DOMElement} node
179
- * @param {string} name
180
- */
181
- deleteValueForAttribute: function (node, name) {
182
- node.removeAttribute(name);
183
- if (process.env.NODE_ENV !== 'production') {
184
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'remove attribute', name);
185
- }
186
- },
187
-
188
- /**
189
- * Deletes the value for a property on a node.
190
- *
191
- * @param {DOMElement} node
192
- * @param {string} name
193
- */
194
- deleteValueForProperty: function (node, name) {
195
- var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
196
- if (propertyInfo) {
197
- var mutationMethod = propertyInfo.mutationMethod;
198
- if (mutationMethod) {
199
- mutationMethod(node, undefined);
200
- } else if (propertyInfo.mustUseProperty) {
201
- var propName = propertyInfo.propertyName;
202
- if (propertyInfo.hasBooleanValue) {
203
- node[propName] = false;
204
- } else {
205
- node[propName] = '';
206
- }
207
- } else {
208
- node.removeAttribute(propertyInfo.attributeName);
209
- }
210
- } else if (DOMProperty.isCustomAttribute(name)) {
211
- node.removeAttribute(name);
212
- }
213
-
214
- if (process.env.NODE_ENV !== 'production') {
215
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'remove attribute', name);
216
- }
217
- }
218
-
219
- };
220
-
221
- module.exports = DOMPropertyOperations;