react 15.3.1-rc.2 → 15.4.0-rc.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 (190) hide show
  1. package/dist/react-with-addons.js +3961 -21387
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2701 -19464
  4. package/dist/react.min.js +2 -6
  5. package/lib/LinkedStateMixin.js +1 -2
  6. package/lib/PooledClass.js +3 -0
  7. package/lib/ReactAddonsDOMDependencies.js +36 -0
  8. package/lib/ReactAddonsDOMDependenciesUMDShim.js +32 -0
  9. package/lib/ReactCSSTransitionGroup.js +60 -42
  10. package/lib/ReactCSSTransitionGroupChild.js +2 -2
  11. package/lib/ReactClass.js +38 -53
  12. package/lib/ReactComponentTreeHook.js +84 -100
  13. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +5 -7
  14. package/lib/ReactCurrentOwner.js +1 -1
  15. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +6 -4
  16. package/lib/ReactElement.js +6 -29
  17. package/lib/ReactElementSymbol.js +20 -0
  18. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +4 -9
  19. package/lib/ReactElementValidator.js +1 -2
  20. package/lib/ReactPropTypeLocationNames.js +1 -0
  21. package/lib/ReactPropTypeLocations.js +2 -11
  22. package/lib/ReactPropTypes.js +30 -13
  23. package/lib/ReactPropTypesSecret.js +1 -0
  24. package/lib/ReactTransitionEvents.js +1 -1
  25. package/lib/ReactTransitionGroup.js +145 -141
  26. package/lib/ReactUMDEntry.js +11 -5
  27. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +4 -6
  28. package/lib/ReactVersion.js +1 -1
  29. package/lib/ReactWithAddons.js +15 -2
  30. package/lib/ReactWithAddonsUMDEntry.js +11 -5
  31. package/lib/canDefineProperty.js +2 -0
  32. package/lib/onlyChild.js +1 -1
  33. package/lib/traverseAllChildren.js +11 -2
  34. package/lib/update.js +6 -7
  35. package/package.json +2 -2
  36. package/lib/AutoFocusUtils.js +0 -24
  37. package/lib/BeforeInputEventPlugin.js +0 -388
  38. package/lib/CSSProperty.js +0 -148
  39. package/lib/CSSPropertyOperations.js +0 -205
  40. package/lib/CallbackQueue.js +0 -106
  41. package/lib/ChangeEventPlugin.js +0 -325
  42. package/lib/DOMChildrenOperations.js +0 -194
  43. package/lib/DOMLazyTree.js +0 -118
  44. package/lib/DOMProperty.js +0 -206
  45. package/lib/DOMPropertyOperations.js +0 -221
  46. package/lib/Danger.js +0 -48
  47. package/lib/DefaultEventPluginOrder.js +0 -27
  48. package/lib/DisabledInputUtils.js +0 -50
  49. package/lib/EnterLeaveEventPlugin.js +0 -105
  50. package/lib/EventConstants.js +0 -97
  51. package/lib/EventPluginHub.js +0 -251
  52. package/lib/EventPluginRegistry.js +0 -247
  53. package/lib/EventPluginUtils.js +0 -229
  54. package/lib/EventPropagators.js +0 -137
  55. package/lib/FallbackCompositionState.js +0 -95
  56. package/lib/HTMLDOMPropertyConfig.js +0 -209
  57. package/lib/LinkedValueUtils.js +0 -136
  58. package/lib/NativeMethodsMixin.js +0 -167
  59. package/lib/ReactBrowserEventEmitter.js +0 -317
  60. package/lib/ReactChildReconciler.js +0 -154
  61. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  62. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  63. package/lib/ReactComponentEnvironment.js +0 -45
  64. package/lib/ReactComponentTreeTestUtils.js +0 -87
  65. package/lib/ReactCompositeComponent.js +0 -920
  66. package/lib/ReactDOM.js +0 -110
  67. package/lib/ReactDOMButton.js +0 -24
  68. package/lib/ReactDOMComponent.js +0 -1005
  69. package/lib/ReactDOMComponentTree.js +0 -188
  70. package/lib/ReactDOMContainerInfo.js +0 -33
  71. package/lib/ReactDOMEmptyComponent.js +0 -60
  72. package/lib/ReactDOMFiber.js +0 -78
  73. package/lib/ReactDOMIDOperations.js +0 -34
  74. package/lib/ReactDOMInput.js +0 -269
  75. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  76. package/lib/ReactDOMOption.js +0 -123
  77. package/lib/ReactDOMSelect.js +0 -201
  78. package/lib/ReactDOMSelection.js +0 -212
  79. package/lib/ReactDOMServer.js +0 -26
  80. package/lib/ReactDOMTextComponent.js +0 -164
  81. package/lib/ReactDOMTextarea.js +0 -155
  82. package/lib/ReactDOMTreeTraversal.js +0 -136
  83. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  84. package/lib/ReactDebugTool.js +0 -307
  85. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  86. package/lib/ReactDefaultInjection.js +0 -84
  87. package/lib/ReactEmptyComponent.js +0 -30
  88. package/lib/ReactErrorUtils.js +0 -76
  89. package/lib/ReactEventEmitterMixin.js +0 -33
  90. package/lib/ReactEventListener.js +0 -157
  91. package/lib/ReactFeatureFlags.js +0 -22
  92. package/lib/ReactHostComponent.js +0 -76
  93. package/lib/ReactHostOperationHistoryHook.js +0 -37
  94. package/lib/ReactInjection.js +0 -36
  95. package/lib/ReactInputSelection.js +0 -124
  96. package/lib/ReactInstanceHandles.js +0 -302
  97. package/lib/ReactInstanceMap.js +0 -48
  98. package/lib/ReactInstrumentation.js +0 -21
  99. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  100. package/lib/ReactMarkupChecksum.js +0 -50
  101. package/lib/ReactMount.js +0 -495
  102. package/lib/ReactMultiChild.js +0 -451
  103. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  104. package/lib/ReactNative.js +0 -71
  105. package/lib/ReactNativeAttributePayload.js +0 -371
  106. package/lib/ReactNativeBaseComponent.js +0 -198
  107. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  108. package/lib/ReactNativeComponentEnvironment.js +0 -31
  109. package/lib/ReactNativeComponentTree.js +0 -68
  110. package/lib/ReactNativeContainerInfo.js +0 -21
  111. package/lib/ReactNativeDOMIDOperations.js +0 -79
  112. package/lib/ReactNativeDefaultInjection.js +0 -101
  113. package/lib/ReactNativeEventEmitter.js +0 -191
  114. package/lib/ReactNativeEventPluginOrder.js +0 -16
  115. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  116. package/lib/ReactNativeMount.js +0 -193
  117. package/lib/ReactNativePropRegistry.js +0 -52
  118. package/lib/ReactNativeReconcileTransaction.js +0 -116
  119. package/lib/ReactNativeTagHandles.js +0 -56
  120. package/lib/ReactNativeTextComponent.js +0 -71
  121. package/lib/ReactNativeTreeTraversal.js +0 -127
  122. package/lib/ReactNodeTypes.js +0 -40
  123. package/lib/ReactNoop.js +0 -173
  124. package/lib/ReactOwner.js +0 -94
  125. package/lib/ReactPerf.js +0 -494
  126. package/lib/ReactReconcileTransaction.js +0 -178
  127. package/lib/ReactReconciler.js +0 -168
  128. package/lib/ReactRef.js +0 -80
  129. package/lib/ReactServerBatchingStrategy.js +0 -22
  130. package/lib/ReactServerRendering.js +0 -90
  131. package/lib/ReactServerRenderingTransaction.js +0 -90
  132. package/lib/ReactServerUpdateQueue.js +0 -141
  133. package/lib/ReactSimpleEmptyComponent.js +0 -37
  134. package/lib/ReactTestMount.js +0 -123
  135. package/lib/ReactTestReconcileTransaction.js +0 -108
  136. package/lib/ReactTestRenderer.js +0 -144
  137. package/lib/ReactTestUtils.js +0 -518
  138. package/lib/ReactUpdateQueue.js +0 -226
  139. package/lib/ReactUpdates.js +0 -251
  140. package/lib/ResponderEventPlugin.js +0 -510
  141. package/lib/ResponderSyntheticEvent.js +0 -39
  142. package/lib/ResponderTouchHistoryStore.js +0 -184
  143. package/lib/SVGDOMPropertyConfig.js +0 -302
  144. package/lib/SelectEventPlugin.js +0 -196
  145. package/lib/SimpleEventPlugin.js +0 -635
  146. package/lib/SyntheticAnimationEvent.js +0 -39
  147. package/lib/SyntheticClipboardEvent.js +0 -38
  148. package/lib/SyntheticCompositionEvent.js +0 -36
  149. package/lib/SyntheticDragEvent.js +0 -36
  150. package/lib/SyntheticEvent.js +0 -267
  151. package/lib/SyntheticFocusEvent.js +0 -36
  152. package/lib/SyntheticInputEvent.js +0 -37
  153. package/lib/SyntheticKeyboardEvent.js +0 -84
  154. package/lib/SyntheticMouseEvent.js +0 -72
  155. package/lib/SyntheticTouchEvent.js +0 -45
  156. package/lib/SyntheticTransitionEvent.js +0 -39
  157. package/lib/SyntheticUIEvent.js +0 -59
  158. package/lib/SyntheticWheelEvent.js +0 -54
  159. package/lib/TapEventPlugin.js +0 -110
  160. package/lib/TouchHistoryMath.js +0 -99
  161. package/lib/Transaction.js +0 -233
  162. package/lib/ViewportMetrics.js +0 -27
  163. package/lib/accumulate.js +0 -46
  164. package/lib/accumulateInto.js +0 -58
  165. package/lib/adler32.js +0 -44
  166. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  167. package/lib/createReactNativeComponentClass.js +0 -42
  168. package/lib/dangerousStyleValue.js +0 -79
  169. package/lib/escapeTextContentForBrowser.js +0 -122
  170. package/lib/findDOMNode.js +0 -60
  171. package/lib/findNodeHandle.js +0 -91
  172. package/lib/forEachAccumulated.js +0 -31
  173. package/lib/getEventCharCode.js +0 -50
  174. package/lib/getEventKey.js +0 -102
  175. package/lib/getEventModifierState.js +0 -43
  176. package/lib/getEventTarget.js +0 -35
  177. package/lib/getHostComponentFromComposite.js +0 -30
  178. package/lib/getNodeForCharacterOffset.js +0 -74
  179. package/lib/getTestDocument.js +0 -21
  180. package/lib/getTextContentAccessor.js +0 -33
  181. package/lib/getVendorPrefixedEventName.js +0 -101
  182. package/lib/instantiateReactComponent.js +0 -119
  183. package/lib/isEventSupported.js +0 -60
  184. package/lib/isTextInputElement.js +0 -51
  185. package/lib/quoteAttributeValueForBrowser.js +0 -26
  186. package/lib/reactComponentExpect.js +0 -217
  187. package/lib/setInnerHTML.js +0 -98
  188. package/lib/setTextContent.js +0 -48
  189. package/lib/shouldUpdateReactComponent.js +0 -42
  190. package/lib/validateDOMNesting.js +0 -369
@@ -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;