react 0.13.3 → 0.14.0-beta1

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 (189) hide show
  1. package/README.md +5 -2
  2. package/addons.js +7 -0
  3. package/dist/JSXTransformer.js +4101 -2432
  4. package/dist/react-with-addons.js +4389 -6277
  5. package/dist/react-with-addons.min.js +6 -8
  6. package/dist/react.js +4028 -5697
  7. package/dist/react.min.js +5 -6
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
  9. package/lib/BeforeInputEventPlugin.js +30 -118
  10. package/lib/CSSCore.js +12 -23
  11. package/lib/CSSProperty.js +4 -3
  12. package/lib/CSSPropertyOperations.js +14 -30
  13. package/lib/CallbackQueue.js +7 -10
  14. package/lib/ChangeEventPlugin.js +26 -88
  15. package/lib/ClientReactRootIndex.js +2 -2
  16. package/lib/DOMChildrenOperations.js +13 -33
  17. package/lib/DOMProperty.js +86 -147
  18. package/lib/DOMPropertyOperations.js +91 -67
  19. package/lib/Danger.js +19 -62
  20. package/lib/DefaultEventPluginOrder.js +2 -12
  21. package/lib/EnterLeaveEventPlugin.js +11 -33
  22. package/lib/EventConstants.js +2 -2
  23. package/lib/EventListener.js +11 -13
  24. package/lib/EventPluginHub.js +44 -47
  25. package/lib/EventPluginRegistry.js +18 -74
  26. package/lib/EventPluginUtils.js +33 -44
  27. package/lib/EventPropagators.js +23 -26
  28. package/lib/ExecutionEnvironment.js +4 -8
  29. package/lib/FallbackCompositionState.js +3 -3
  30. package/lib/HTMLDOMPropertyConfig.js +15 -20
  31. package/lib/LinkedStateMixin.js +3 -6
  32. package/lib/LinkedValueUtils.js +71 -89
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +20 -11
  35. package/lib/React.js +9 -129
  36. package/lib/ReactBrowserComponentMixin.js +9 -2
  37. package/lib/ReactBrowserEventEmitter.js +26 -82
  38. package/lib/ReactCSSTransitionGroup.js +13 -24
  39. package/lib/ReactCSSTransitionGroupChild.js +26 -28
  40. package/lib/ReactChildReconciler.js +11 -19
  41. package/lib/ReactChildren.js +24 -31
  42. package/lib/ReactClass.js +96 -267
  43. package/lib/ReactComponent.js +28 -57
  44. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  45. package/lib/ReactComponentEnvironment.js +6 -12
  46. package/lib/ReactComponentWithPureRenderMixin.js +6 -7
  47. package/lib/ReactCompositeComponent.js +115 -381
  48. package/lib/ReactCurrentOwner.js +1 -3
  49. package/lib/ReactDOM.js +4 -2
  50. package/lib/ReactDOMButton.js +16 -28
  51. package/lib/ReactDOMClient.js +90 -0
  52. package/lib/ReactDOMComponent.js +468 -156
  53. package/lib/ReactDOMIDOperations.js +25 -22
  54. package/lib/ReactDOMInput.js +79 -108
  55. package/lib/ReactDOMOption.js +58 -20
  56. package/lib/ReactDOMSelect.js +95 -83
  57. package/lib/ReactDOMSelection.js +5 -20
  58. package/lib/ReactDOMServer.js +24 -0
  59. package/lib/ReactDOMTextComponent.js +17 -18
  60. package/lib/ReactDOMTextarea.js +44 -69
  61. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  62. package/lib/ReactDefaultInjection.js +20 -76
  63. package/lib/ReactDefaultPerf.js +36 -69
  64. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  65. package/lib/ReactElement.js +26 -120
  66. package/lib/ReactElementValidator.js +56 -192
  67. package/lib/ReactEmptyComponent.js +7 -11
  68. package/lib/ReactErrorUtils.js +3 -3
  69. package/lib/ReactEventEmitterMixin.js +3 -13
  70. package/lib/ReactEventListener.js +58 -40
  71. package/lib/ReactFragment.js +33 -59
  72. package/lib/ReactInjection.js +1 -1
  73. package/lib/ReactInputSelection.js +14 -23
  74. package/lib/ReactInstanceHandles.js +29 -58
  75. package/lib/ReactInstanceMap.js +5 -5
  76. package/lib/ReactIsomorphic.js +70 -0
  77. package/lib/ReactLink.js +2 -4
  78. package/lib/ReactMarkupChecksum.js +5 -10
  79. package/lib/ReactMount.js +142 -285
  80. package/lib/ReactMultiChild.js +19 -45
  81. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  82. package/lib/ReactNativeComponent.js +6 -15
  83. package/lib/ReactNoopUpdateQueue.js +118 -0
  84. package/lib/ReactOwner.js +7 -24
  85. package/lib/ReactPerf.js +8 -12
  86. package/lib/ReactPropTransferer.js +4 -4
  87. package/lib/ReactPropTypeLocationNames.js +2 -2
  88. package/lib/ReactPropTypeLocations.js +1 -1
  89. package/lib/ReactPropTypes.js +41 -61
  90. package/lib/ReactReconcileTransaction.js +11 -36
  91. package/lib/ReactReconciler.js +14 -26
  92. package/lib/ReactRef.js +5 -8
  93. package/lib/ReactRootIndex.js +2 -2
  94. package/lib/ReactServerBatchingStrategy.js +23 -0
  95. package/lib/ReactServerRendering.js +20 -15
  96. package/lib/ReactServerRenderingTransaction.js +9 -34
  97. package/lib/ReactStateSetters.js +6 -6
  98. package/lib/ReactTestUtils.js +137 -190
  99. package/lib/ReactTransitionChildMapping.js +5 -7
  100. package/lib/ReactTransitionEvents.js +5 -5
  101. package/lib/ReactTransitionGroup.js +30 -52
  102. package/lib/ReactUpdateQueue.js +69 -107
  103. package/lib/ReactUpdates.js +26 -81
  104. package/lib/ReactWithAddons.js +5 -6
  105. package/lib/SVGDOMPropertyConfig.js +39 -4
  106. package/lib/SelectEventPlugin.js +31 -33
  107. package/lib/ServerReactRootIndex.js +2 -2
  108. package/lib/SimpleEventPlugin.js +138 -130
  109. package/lib/SyntheticClipboardEvent.js +5 -9
  110. package/lib/SyntheticCompositionEvent.js +4 -10
  111. package/lib/SyntheticDragEvent.js +3 -3
  112. package/lib/SyntheticEvent.js +14 -15
  113. package/lib/SyntheticFocusEvent.js +3 -3
  114. package/lib/SyntheticInputEvent.js +4 -10
  115. package/lib/SyntheticKeyboardEvent.js +6 -6
  116. package/lib/SyntheticMouseEvent.js +10 -16
  117. package/lib/SyntheticTouchEvent.js +3 -3
  118. package/lib/SyntheticUIEvent.js +5 -5
  119. package/lib/SyntheticWheelEvent.js +13 -17
  120. package/lib/Transaction.js +22 -28
  121. package/lib/ViewportMetrics.js +2 -2
  122. package/lib/accumulateInto.js +2 -5
  123. package/lib/adler32.js +2 -4
  124. package/lib/camelize.js +4 -2
  125. package/lib/camelizeStyleName.js +2 -2
  126. package/lib/cloneWithProps.js +6 -12
  127. package/lib/containsNode.js +29 -16
  128. package/lib/createArrayFromMixed.js +17 -16
  129. package/lib/createNodesFromMarkup.js +6 -8
  130. package/lib/dangerousStyleValue.js +2 -3
  131. package/lib/deprecated.js +47 -0
  132. package/lib/emptyFunction.js +10 -4
  133. package/lib/emptyObject.js +1 -1
  134. package/lib/escapeTextContentForBrowser.js +1 -1
  135. package/lib/findDOMNode.js +7 -27
  136. package/lib/flattenChildren.js +4 -10
  137. package/lib/focusNode.js +2 -3
  138. package/lib/forEachAccumulated.js +3 -3
  139. package/lib/getActiveElement.js +4 -2
  140. package/lib/getEventCharCode.js +2 -2
  141. package/lib/getEventKey.js +1 -1
  142. package/lib/getEventModifierState.js +1 -2
  143. package/lib/getEventTarget.js +1 -1
  144. package/lib/getIteratorFn.js +2 -4
  145. package/lib/getMarkupWrap.js +18 -40
  146. package/lib/getNodeForCharacterOffset.js +1 -1
  147. package/lib/getTextContentAccessor.js +2 -4
  148. package/lib/getUnboundedScrollPosition.js +1 -1
  149. package/lib/hyphenate.js +3 -1
  150. package/lib/hyphenateStyleName.js +2 -2
  151. package/lib/instantiateReactComponent.js +23 -43
  152. package/lib/invariant.js +8 -12
  153. package/lib/isEventSupported.js +7 -10
  154. package/lib/isNode.js +4 -6
  155. package/lib/isTextInputElement.js +3 -4
  156. package/lib/isTextNode.js +3 -1
  157. package/lib/joinClasses.js +3 -3
  158. package/lib/keyMirror.js +3 -6
  159. package/lib/keyOf.js +4 -3
  160. package/lib/mapObject.js +1 -1
  161. package/lib/memoizeStringOnly.js +2 -2
  162. package/lib/onlyChild.js +2 -5
  163. package/lib/performance.js +2 -5
  164. package/lib/performanceNow.js +3 -1
  165. package/lib/quoteAttributeValueForBrowser.js +1 -1
  166. package/lib/renderSubtreeIntoContainer.js +16 -0
  167. package/lib/setInnerHTML.js +11 -8
  168. package/lib/setTextContent.js +3 -3
  169. package/lib/shallowCompare.js +24 -0
  170. package/lib/shallowEqual.js +17 -11
  171. package/lib/shouldUpdateReactComponent.js +3 -64
  172. package/lib/toArray.js +8 -19
  173. package/lib/traverseAllChildren.js +23 -90
  174. package/lib/update.js +25 -85
  175. package/lib/validateDOMNesting.js +363 -0
  176. package/lib/warning.js +15 -17
  177. package/package.json +3 -3
  178. package/react.js +53 -1
  179. package/lib/LocalEventTrapMixin.js +0 -53
  180. package/lib/MobileSafariClickEventPlugin.js +0 -56
  181. package/lib/ReactContext.js +0 -74
  182. package/lib/ReactDOMForm.js +0 -47
  183. package/lib/ReactDOMIframe.js +0 -43
  184. package/lib/ReactDOMImg.js +0 -44
  185. package/lib/ReactLifeCycle.js +0 -35
  186. package/lib/ReactPutListenerQueue.js +0 -54
  187. package/lib/createFullPageComponent.js +0 -58
  188. package/lib/cx.js +0 -52
  189. package/lib/getReactRootElementInContainer.js +0 -33
@@ -41,7 +41,7 @@ assign(CallbackQueue.prototype, {
41
41
  * @param {?object} context Context to call `callback` with.
42
42
  * @internal
43
43
  */
44
- enqueue: function(callback, context) {
44
+ enqueue: function (callback, context) {
45
45
  this._callbacks = this._callbacks || [];
46
46
  this._contexts = this._contexts || [];
47
47
  this._callbacks.push(callback);
@@ -54,17 +54,14 @@ assign(CallbackQueue.prototype, {
54
54
  *
55
55
  * @internal
56
56
  */
57
- notifyAll: function() {
57
+ notifyAll: function () {
58
58
  var callbacks = this._callbacks;
59
59
  var contexts = this._contexts;
60
60
  if (callbacks) {
61
- ("production" !== process.env.NODE_ENV ? invariant(
62
- callbacks.length === contexts.length,
63
- 'Mismatched list of contexts in callback queue'
64
- ) : invariant(callbacks.length === contexts.length));
61
+ !(callbacks.length === contexts.length) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Mismatched list of contexts in callback queue') : invariant(false) : undefined;
65
62
  this._callbacks = null;
66
63
  this._contexts = null;
67
- for (var i = 0, l = callbacks.length; i < l; i++) {
64
+ for (var i = 0; i < callbacks.length; i++) {
68
65
  callbacks[i].call(contexts[i]);
69
66
  }
70
67
  callbacks.length = 0;
@@ -77,7 +74,7 @@ assign(CallbackQueue.prototype, {
77
74
  *
78
75
  * @internal
79
76
  */
80
- reset: function() {
77
+ reset: function () {
81
78
  this._callbacks = null;
82
79
  this._contexts = null;
83
80
  },
@@ -85,7 +82,7 @@ assign(CallbackQueue.prototype, {
85
82
  /**
86
83
  * `PooledClass` looks for this.
87
84
  */
88
- destructor: function() {
85
+ destructor: function () {
89
86
  this.reset();
90
87
  }
91
88
 
@@ -93,4 +90,4 @@ assign(CallbackQueue.prototype, {
93
90
 
94
91
  PooledClass.addPoolingTo(CallbackQueue);
95
92
 
96
- module.exports = CallbackQueue;
93
+ module.exports = CallbackQueue;
@@ -27,19 +27,10 @@ var topLevelTypes = EventConstants.topLevelTypes;
27
27
  var eventTypes = {
28
28
  change: {
29
29
  phasedRegistrationNames: {
30
- bubbled: keyOf({onChange: null}),
31
- captured: keyOf({onChangeCapture: null})
30
+ bubbled: keyOf({ onChange: null }),
31
+ captured: keyOf({ onChangeCapture: null })
32
32
  },
33
- dependencies: [
34
- topLevelTypes.topBlur,
35
- topLevelTypes.topChange,
36
- topLevelTypes.topClick,
37
- topLevelTypes.topFocus,
38
- topLevelTypes.topInput,
39
- topLevelTypes.topKeyDown,
40
- topLevelTypes.topKeyUp,
41
- topLevelTypes.topSelectionChange
42
- ]
33
+ dependencies: [topLevelTypes.topBlur, topLevelTypes.topChange, topLevelTypes.topClick, topLevelTypes.topFocus, topLevelTypes.topInput, topLevelTypes.topKeyDown, topLevelTypes.topKeyUp, topLevelTypes.topSelectionChange]
43
34
  }
44
35
  };
45
36
 
@@ -55,26 +46,18 @@ var activeElementValueProp = null;
55
46
  * SECTION: handle `change` event
56
47
  */
57
48
  function shouldUseChangeEvent(elem) {
58
- return (
59
- elem.nodeName === 'SELECT' ||
60
- (elem.nodeName === 'INPUT' && elem.type === 'file')
61
- );
49
+ var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
50
+ return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
62
51
  }
63
52
 
64
53
  var doesChangeEventBubble = false;
65
54
  if (ExecutionEnvironment.canUseDOM) {
66
55
  // See `handleChange` comment below
67
- doesChangeEventBubble = isEventSupported('change') && (
68
- (!('documentMode' in document) || document.documentMode > 8)
69
- );
56
+ doesChangeEventBubble = isEventSupported('change') && (!('documentMode' in document) || document.documentMode > 8);
70
57
  }
71
58
 
72
59
  function manualDispatchChangeEvent(nativeEvent) {
73
- var event = SyntheticEvent.getPooled(
74
- eventTypes.change,
75
- activeElementID,
76
- nativeEvent
77
- );
60
+ var event = SyntheticEvent.getPooled(eventTypes.change, activeElementID, nativeEvent);
78
61
  EventPropagators.accumulateTwoPhaseDispatches(event);
79
62
 
80
63
  // If change and propertychange bubbled, we'd just bind to it like all the
@@ -111,18 +94,12 @@ function stopWatchingForChangeEventIE8() {
111
94
  activeElementID = null;
112
95
  }
113
96
 
114
- function getTargetIDForChangeEvent(
115
- topLevelType,
116
- topLevelTarget,
117
- topLevelTargetID) {
97
+ function getTargetIDForChangeEvent(topLevelType, topLevelTarget, topLevelTargetID) {
118
98
  if (topLevelType === topLevelTypes.topChange) {
119
99
  return topLevelTargetID;
120
100
  }
121
101
  }
122
- function handleEventsForChangeEventIE8(
123
- topLevelType,
124
- topLevelTarget,
125
- topLevelTargetID) {
102
+ function handleEventsForChangeEventIE8(topLevelType, topLevelTarget, topLevelTargetID) {
126
103
  if (topLevelType === topLevelTypes.topFocus) {
127
104
  // stopWatching() should be a noop here but we call it just in case we
128
105
  // missed a blur event somehow.
@@ -133,7 +110,6 @@ function handleEventsForChangeEventIE8(
133
110
  }
134
111
  }
135
112
 
136
-
137
113
  /**
138
114
  * SECTION: handle `input` event
139
115
  */
@@ -141,20 +117,18 @@ var isInputEventSupported = false;
141
117
  if (ExecutionEnvironment.canUseDOM) {
142
118
  // IE9 claims to support the input event but fails to trigger it when
143
119
  // deleting text, so we ignore its input events
144
- isInputEventSupported = isEventSupported('input') && (
145
- (!('documentMode' in document) || document.documentMode > 9)
146
- );
120
+ isInputEventSupported = isEventSupported('input') && (!('documentMode' in document) || document.documentMode > 9);
147
121
  }
148
122
 
149
123
  /**
150
124
  * (For old IE.) Replacement getter/setter for the `value` property that gets
151
125
  * set on the active element.
152
126
  */
153
- var newValueProp = {
154
- get: function() {
127
+ var newValueProp = {
128
+ get: function () {
155
129
  return activeElementValueProp.get.call(this);
156
130
  },
157
- set: function(val) {
131
+ set: function (val) {
158
132
  // Cast to a string so we can do equality checks.
159
133
  activeElementValue = '' + val;
160
134
  activeElementValueProp.set.call(this, val);
@@ -170,10 +144,7 @@ function startWatchingForValueChange(target, targetID) {
170
144
  activeElement = target;
171
145
  activeElementID = targetID;
172
146
  activeElementValue = target.value;
173
- activeElementValueProp = Object.getOwnPropertyDescriptor(
174
- target.constructor.prototype,
175
- 'value'
176
- );
147
+ activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value');
177
148
 
178
149
  Object.defineProperty(activeElement, 'value', newValueProp);
179
150
  activeElement.attachEvent('onpropertychange', handlePropertyChange);
@@ -218,10 +189,7 @@ function handlePropertyChange(nativeEvent) {
218
189
  /**
219
190
  * If a `change` event should be fired, returns the target's ID.
220
191
  */
221
- function getTargetIDForInputEvent(
222
- topLevelType,
223
- topLevelTarget,
224
- topLevelTargetID) {
192
+ function getTargetIDForInputEvent(topLevelType, topLevelTarget, topLevelTargetID) {
225
193
  if (topLevelType === topLevelTypes.topInput) {
226
194
  // In modern browsers (i.e., not IE8 or IE9), the input event is exactly
227
195
  // what we want so fall through here and trigger an abstract event
@@ -230,10 +198,7 @@ function getTargetIDForInputEvent(
230
198
  }
231
199
 
232
200
  // For IE8 and IE9.
233
- function handleEventsForInputEventIE(
234
- topLevelType,
235
- topLevelTarget,
236
- topLevelTargetID) {
201
+ function handleEventsForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
237
202
  if (topLevelType === topLevelTypes.topFocus) {
238
203
  // In IE8, we can capture almost all .value changes by adding a
239
204
  // propertychange handler and looking for events with propertyName
@@ -256,13 +221,8 @@ function handleEventsForInputEventIE(
256
221
  }
257
222
 
258
223
  // For IE8 and IE9.
259
- function getTargetIDForInputEventIE(
260
- topLevelType,
261
- topLevelTarget,
262
- topLevelTargetID) {
263
- if (topLevelType === topLevelTypes.topSelectionChange ||
264
- topLevelType === topLevelTypes.topKeyUp ||
265
- topLevelType === topLevelTypes.topKeyDown) {
224
+ function getTargetIDForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
225
+ if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) {
266
226
  // On the selectionchange event, the target is just document which isn't
267
227
  // helpful for us so just check activeElement instead.
268
228
  //
@@ -280,7 +240,6 @@ function getTargetIDForInputEventIE(
280
240
  }
281
241
  }
282
242
 
283
-
284
243
  /**
285
244
  * SECTION: handle `click` event
286
245
  */
@@ -288,16 +247,10 @@ function shouldUseClickEvent(elem) {
288
247
  // Use the `click` event to detect changes to checkbox and radio inputs.
289
248
  // This approach works across all browsers, whereas `change` does not fire
290
249
  // until `blur` in IE8.
291
- return (
292
- elem.nodeName === 'INPUT' &&
293
- (elem.type === 'checkbox' || elem.type === 'radio')
294
- );
250
+ return elem.nodeName && elem.nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
295
251
  }
296
252
 
297
- function getTargetIDForClickEvent(
298
- topLevelType,
299
- topLevelTarget,
300
- topLevelTargetID) {
253
+ function getTargetIDForClickEvent(topLevelType, topLevelTarget, topLevelTargetID) {
301
254
  if (topLevelType === topLevelTypes.topClick) {
302
255
  return topLevelTargetID;
303
256
  }
@@ -325,11 +278,7 @@ var ChangeEventPlugin = {
325
278
  * @return {*} An accumulation of synthetic events.
326
279
  * @see {EventPluginHub.extractEvents}
327
280
  */
328
- extractEvents: function(
329
- topLevelType,
330
- topLevelTarget,
331
- topLevelTargetID,
332
- nativeEvent) {
281
+ extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
333
282
 
334
283
  var getTargetIDFunc, handleEventFunc;
335
284
  if (shouldUseChangeEvent(topLevelTarget)) {
@@ -350,31 +299,20 @@ var ChangeEventPlugin = {
350
299
  }
351
300
 
352
301
  if (getTargetIDFunc) {
353
- var targetID = getTargetIDFunc(
354
- topLevelType,
355
- topLevelTarget,
356
- topLevelTargetID
357
- );
302
+ var targetID = getTargetIDFunc(topLevelType, topLevelTarget, topLevelTargetID);
358
303
  if (targetID) {
359
- var event = SyntheticEvent.getPooled(
360
- eventTypes.change,
361
- targetID,
362
- nativeEvent
363
- );
304
+ var event = SyntheticEvent.getPooled(eventTypes.change, targetID, nativeEvent);
305
+ event.type = 'change';
364
306
  EventPropagators.accumulateTwoPhaseDispatches(event);
365
307
  return event;
366
308
  }
367
309
  }
368
310
 
369
311
  if (handleEventFunc) {
370
- handleEventFunc(
371
- topLevelType,
372
- topLevelTarget,
373
- topLevelTargetID
374
- );
312
+ handleEventFunc(topLevelType, topLevelTarget, topLevelTargetID);
375
313
  }
376
314
  }
377
315
 
378
316
  };
379
317
 
380
- module.exports = ChangeEventPlugin;
318
+ module.exports = ChangeEventPlugin;
@@ -15,9 +15,9 @@
15
15
  var nextReactRootIndex = 0;
16
16
 
17
17
  var ClientReactRootIndex = {
18
- createReactRootIndex: function() {
18
+ createReactRootIndex: function () {
19
19
  return nextReactRootIndex++;
20
20
  }
21
21
  };
22
22
 
23
- module.exports = ClientReactRootIndex;
23
+ module.exports = ClientReactRootIndex;
@@ -31,10 +31,12 @@ function insertChildAt(parentNode, childNode, index) {
31
31
  // rely exclusively on `insertBefore(node, null)` instead of also using
32
32
  // `appendChild(node)`. However, using `undefined` is not allowed by all
33
33
  // browsers so we must replace it with `null`.
34
- parentNode.insertBefore(
35
- childNode,
36
- parentNode.childNodes[index] || null
37
- );
34
+
35
+ // fix render order error in safari
36
+ // IE8 will throw error when index out of list size.
37
+ var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index);
38
+
39
+ parentNode.insertBefore(childNode, beforeChild);
38
40
  }
39
41
 
40
42
  /**
@@ -54,7 +56,7 @@ var DOMChildrenOperations = {
54
56
  * @param {array<string>} markupList List of markup strings.
55
57
  * @internal
56
58
  */
57
- processUpdates: function(updates, markupList) {
59
+ processUpdates: function (updates, markupList) {
58
60
  var update;
59
61
  // Mapping from parent IDs to initial child orderings.
60
62
  var initialChildren = null;
@@ -63,23 +65,12 @@ var DOMChildrenOperations = {
63
65
 
64
66
  for (var i = 0; i < updates.length; i++) {
65
67
  update = updates[i];
66
- if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
67
- update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
68
+ if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING || update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
68
69
  var updatedIndex = update.fromIndex;
69
70
  var updatedChild = update.parentNode.childNodes[updatedIndex];
70
71
  var parentID = update.parentID;
71
72
 
72
- ("production" !== process.env.NODE_ENV ? invariant(
73
- updatedChild,
74
- 'processUpdates(): Unable to find child %s of element. This ' +
75
- 'probably means the DOM was unexpectedly mutated (e.g., by the ' +
76
- 'browser), usually due to forgetting a <tbody> when using tables, ' +
77
- 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' +
78
- 'in an <svg> parent. Try inspecting the child nodes of the element ' +
79
- 'with React ID `%s`.',
80
- updatedIndex,
81
- parentID
82
- ) : invariant(updatedChild));
73
+ !updatedChild ? 'production' !== process.env.NODE_ENV ? 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;
83
74
 
84
75
  initialChildren = initialChildren || {};
85
76
  initialChildren[parentID] = initialChildren[parentID] || [];
@@ -103,24 +94,13 @@ var DOMChildrenOperations = {
103
94
  update = updates[k];
104
95
  switch (update.type) {
105
96
  case ReactMultiChildUpdateTypes.INSERT_MARKUP:
106
- insertChildAt(
107
- update.parentNode,
108
- renderedMarkup[update.markupIndex],
109
- update.toIndex
110
- );
97
+ insertChildAt(update.parentNode, renderedMarkup[update.markupIndex], update.toIndex);
111
98
  break;
112
99
  case ReactMultiChildUpdateTypes.MOVE_EXISTING:
113
- insertChildAt(
114
- update.parentNode,
115
- initialChildren[update.parentID][update.fromIndex],
116
- update.toIndex
117
- );
100
+ insertChildAt(update.parentNode, initialChildren[update.parentID][update.fromIndex], update.toIndex);
118
101
  break;
119
102
  case ReactMultiChildUpdateTypes.TEXT_CONTENT:
120
- setTextContent(
121
- update.parentNode,
122
- update.textContent
123
- );
103
+ setTextContent(update.parentNode, update.textContent);
124
104
  break;
125
105
  case ReactMultiChildUpdateTypes.REMOVE_NODE:
126
106
  // Already removed by the for-loop above.
@@ -131,4 +111,4 @@ var DOMChildrenOperations = {
131
111
 
132
112
  };
133
113
 
134
- module.exports = DOMChildrenOperations;
114
+ module.exports = DOMChildrenOperations;
@@ -10,8 +10,6 @@
10
10
  * @typechecks static-only
11
11
  */
12
12
 
13
- /*jslint bitwise: true */
14
-
15
13
  'use strict';
16
14
 
17
15
  var invariant = require("./invariant");
@@ -50,6 +48,9 @@ var DOMPropertyInjection = {
50
48
  * attribute name. Attribute names not specified use the **lowercase**
51
49
  * normalized name.
52
50
  *
51
+ * DOMAttributeNamespaces: object mapping React attribute name to the DOM
52
+ * attribute namespace URL. (Attribute names not specified use no namespace.)
53
+ *
53
54
  * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
54
55
  * Property names not specified use the normalized name.
55
56
  *
@@ -58,92 +59,68 @@ var DOMPropertyInjection = {
58
59
  *
59
60
  * @param {object} domPropertyConfig the config as described above.
60
61
  */
61
- injectDOMPropertyConfig: function(domPropertyConfig) {
62
+ injectDOMPropertyConfig: function (domPropertyConfig) {
63
+ var Injection = DOMPropertyInjection;
62
64
  var Properties = domPropertyConfig.Properties || {};
65
+ var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {};
63
66
  var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
64
67
  var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
65
68
  var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
66
69
 
67
70
  if (domPropertyConfig.isCustomAttribute) {
68
- DOMProperty._isCustomAttributeFunctions.push(
69
- domPropertyConfig.isCustomAttribute
70
- );
71
+ DOMProperty._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute);
71
72
  }
72
73
 
73
74
  for (var propName in Properties) {
74
- ("production" !== process.env.NODE_ENV ? invariant(
75
- !DOMProperty.isStandardName.hasOwnProperty(propName),
76
- 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
77
- '\'%s\' which has already been injected. You may be accidentally ' +
78
- 'injecting the same DOM property config twice, or you may be ' +
79
- 'injecting two configs that have conflicting property names.',
80
- propName
81
- ) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
82
-
83
- DOMProperty.isStandardName[propName] = true;
75
+ !!DOMProperty.properties.hasOwnProperty(propName) ? 'production' !== process.env.NODE_ENV ? 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) : invariant(false) : undefined;
84
76
 
85
77
  var lowerCased = propName.toLowerCase();
86
- DOMProperty.getPossibleStandardName[lowerCased] = propName;
78
+ var propConfig = Properties[propName];
79
+
80
+ var propertyInfo = {
81
+ attributeName: lowerCased,
82
+ attributeNamespace: null,
83
+ propertyName: propName,
84
+ mutationMethod: null,
85
+
86
+ mustUseAttribute: checkMask(propConfig, Injection.MUST_USE_ATTRIBUTE),
87
+ mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
88
+ hasSideEffects: checkMask(propConfig, Injection.HAS_SIDE_EFFECTS),
89
+ hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
90
+ hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE),
91
+ hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE),
92
+ hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE)
93
+ };
94
+
95
+ !(!propertyInfo.mustUseAttribute || !propertyInfo.mustUseProperty) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'DOMProperty: Cannot require using both attribute and property: %s', propName) : invariant(false) : undefined;
96
+ !(propertyInfo.mustUseProperty || !propertyInfo.hasSideEffects) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'DOMProperty: Properties that have side effects must use property: %s', propName) : invariant(false) : undefined;
97
+ !(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName) : invariant(false) : undefined;
98
+
99
+ if ('production' !== process.env.NODE_ENV) {
100
+ DOMProperty.getPossibleStandardName[lowerCased] = propName;
101
+ }
87
102
 
88
103
  if (DOMAttributeNames.hasOwnProperty(propName)) {
89
104
  var attributeName = DOMAttributeNames[propName];
90
- DOMProperty.getPossibleStandardName[attributeName] = propName;
91
- DOMProperty.getAttributeName[propName] = attributeName;
92
- } else {
93
- DOMProperty.getAttributeName[propName] = lowerCased;
105
+ propertyInfo.attributeName = attributeName;
106
+ if ('production' !== process.env.NODE_ENV) {
107
+ DOMProperty.getPossibleStandardName[attributeName] = propName;
108
+ }
109
+ }
110
+
111
+ if (DOMAttributeNamespaces.hasOwnProperty(propName)) {
112
+ propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName];
94
113
  }
95
114
 
96
- DOMProperty.getPropertyName[propName] =
97
- DOMPropertyNames.hasOwnProperty(propName) ?
98
- DOMPropertyNames[propName] :
99
- propName;
115
+ if (DOMPropertyNames.hasOwnProperty(propName)) {
116
+ propertyInfo.propertyName = DOMPropertyNames[propName];
117
+ }
100
118
 
101
119
  if (DOMMutationMethods.hasOwnProperty(propName)) {
102
- DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
103
- } else {
104
- DOMProperty.getMutationMethod[propName] = null;
120
+ propertyInfo.mutationMethod = DOMMutationMethods[propName];
105
121
  }
106
122
 
107
- var propConfig = Properties[propName];
108
- DOMProperty.mustUseAttribute[propName] =
109
- checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
110
- DOMProperty.mustUseProperty[propName] =
111
- checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
112
- DOMProperty.hasSideEffects[propName] =
113
- checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
114
- DOMProperty.hasBooleanValue[propName] =
115
- checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
116
- DOMProperty.hasNumericValue[propName] =
117
- checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
118
- DOMProperty.hasPositiveNumericValue[propName] =
119
- checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
120
- DOMProperty.hasOverloadedBooleanValue[propName] =
121
- checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
122
-
123
- ("production" !== process.env.NODE_ENV ? invariant(
124
- !DOMProperty.mustUseAttribute[propName] ||
125
- !DOMProperty.mustUseProperty[propName],
126
- 'DOMProperty: Cannot require using both attribute and property: %s',
127
- propName
128
- ) : invariant(!DOMProperty.mustUseAttribute[propName] ||
129
- !DOMProperty.mustUseProperty[propName]));
130
- ("production" !== process.env.NODE_ENV ? invariant(
131
- DOMProperty.mustUseProperty[propName] ||
132
- !DOMProperty.hasSideEffects[propName],
133
- 'DOMProperty: Properties that have side effects must use property: %s',
134
- propName
135
- ) : invariant(DOMProperty.mustUseProperty[propName] ||
136
- !DOMProperty.hasSideEffects[propName]));
137
- ("production" !== process.env.NODE_ENV ? invariant(
138
- !!DOMProperty.hasBooleanValue[propName] +
139
- !!DOMProperty.hasNumericValue[propName] +
140
- !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
141
- 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
142
- 'numeric value, but not a combination: %s',
143
- propName
144
- ) : invariant(!!DOMProperty.hasBooleanValue[propName] +
145
- !!DOMProperty.hasNumericValue[propName] +
146
- !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
123
+ DOMProperty.properties[propName] = propertyInfo;
147
124
  }
148
125
  }
149
126
  };
@@ -167,87 +144,49 @@ var DOMProperty = {
167
144
  ID_ATTRIBUTE_NAME: 'data-reactid',
168
145
 
169
146
  /**
170
- * Checks whether a property name is a standard property.
171
- * @type {Object}
172
- */
173
- isStandardName: {},
147
+ * Map from property "standard name" to an object with info about how to set
148
+ * the property in the DOM. Each object contains:
149
+ *
150
+ * attributeName:
151
+ * Used when rendering markup or with `*Attribute()`.
152
+ * attributeNamespace
153
+ * propertyName:
154
+ * Used on DOM node instances. (This includes properties that mutate due to
155
+ * external factors.)
156
+ * mutationMethod:
157
+ * If non-null, used instead of the property or `setAttribute()` after
158
+ * initial render.
159
+ * mustUseAttribute:
160
+ * Whether the property must be accessed and mutated using `*Attribute()`.
161
+ * (This includes anything that fails `<propName> in <element>`.)
162
+ * mustUseProperty:
163
+ * Whether the property must be accessed and mutated as an object property.
164
+ * hasSideEffects:
165
+ * Whether or not setting a value causes side effects such as triggering
166
+ * resources to be loaded or text selection changes. If true, we read from
167
+ * the DOM before updating to ensure that the value is only set if it has
168
+ * changed.
169
+ * hasBooleanValue:
170
+ * Whether the property should be removed when set to a falsey value.
171
+ * hasNumericValue:
172
+ * Whether the property must be numeric or parse as a numeric and should be
173
+ * removed when set to a falsey value.
174
+ * hasPositiveNumericValue:
175
+ * Whether the property must be positive numeric or parse as a positive
176
+ * numeric and should be removed when set to a falsey value.
177
+ * hasOverloadedBooleanValue:
178
+ * Whether the property can be used as a flag as well as with a value.
179
+ * Removed when strictly equal to false; present without a value when
180
+ * strictly equal to true; present with a value otherwise.
181
+ */
182
+ properties: {},
174
183
 
175
184
  /**
176
185
  * Mapping from lowercase property names to the properly cased version, used
177
- * to warn in the case of missing properties.
178
- * @type {Object}
179
- */
180
- getPossibleStandardName: {},
181
-
182
- /**
183
- * Mapping from normalized names to attribute names that differ. Attribute
184
- * names are used when rendering markup or with `*Attribute()`.
185
- * @type {Object}
186
- */
187
- getAttributeName: {},
188
-
189
- /**
190
- * Mapping from normalized names to properties on DOM node instances.
191
- * (This includes properties that mutate due to external factors.)
192
- * @type {Object}
193
- */
194
- getPropertyName: {},
195
-
196
- /**
197
- * Mapping from normalized names to mutation methods. This will only exist if
198
- * mutation cannot be set simply by the property or `setAttribute()`.
199
- * @type {Object}
200
- */
201
- getMutationMethod: {},
202
-
203
- /**
204
- * Whether the property must be accessed and mutated as an object property.
205
- * @type {Object}
206
- */
207
- mustUseAttribute: {},
208
-
209
- /**
210
- * Whether the property must be accessed and mutated using `*Attribute()`.
211
- * (This includes anything that fails `<propName> in <element>`.)
212
- * @type {Object}
213
- */
214
- mustUseProperty: {},
215
-
216
- /**
217
- * Whether or not setting a value causes side effects such as triggering
218
- * resources to be loaded or text selection changes. We must ensure that
219
- * the value is only set if it has changed.
220
- * @type {Object}
221
- */
222
- hasSideEffects: {},
223
-
224
- /**
225
- * Whether the property should be removed when set to a falsey value.
226
- * @type {Object}
227
- */
228
- hasBooleanValue: {},
229
-
230
- /**
231
- * Whether the property must be numeric or parse as a
232
- * numeric and should be removed when set to a falsey value.
233
- * @type {Object}
234
- */
235
- hasNumericValue: {},
236
-
237
- /**
238
- * Whether the property must be positive numeric or parse as a positive
239
- * numeric and should be removed when set to a falsey value.
240
- * @type {Object}
241
- */
242
- hasPositiveNumericValue: {},
243
-
244
- /**
245
- * Whether the property can be used as a flag as well as with a value. Removed
246
- * when strictly equal to false; present without a value when strictly equal
247
- * to true; present with a value otherwise.
186
+ * to warn in the case of missing properties. Available only in __DEV__.
248
187
  * @type {Object}
249
188
  */
250
- hasOverloadedBooleanValue: {},
189
+ getPossibleStandardName: 'production' !== process.env.NODE_ENV ? {} : null,
251
190
 
252
191
  /**
253
192
  * All of the isCustomAttribute() functions that have been injected.
@@ -258,7 +197,7 @@ var DOMProperty = {
258
197
  * Checks whether a property name is a custom attribute.
259
198
  * @method
260
199
  */
261
- isCustomAttribute: function(attributeName) {
200
+ isCustomAttribute: function (attributeName) {
262
201
  for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
263
202
  var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
264
203
  if (isCustomAttributeFn(attributeName)) {
@@ -276,7 +215,7 @@ var DOMProperty = {
276
215
  * TODO: Is it better to grab all the possible properties when creating an
277
216
  * element to avoid having to create the same element twice?
278
217
  */
279
- getDefaultValueForProperty: function(nodeName, prop) {
218
+ getDefaultValueForProperty: function (nodeName, prop) {
280
219
  var nodeDefaults = defaultValueCache[nodeName];
281
220
  var testElement;
282
221
  if (!nodeDefaults) {
@@ -292,4 +231,4 @@ var DOMProperty = {
292
231
  injection: DOMPropertyInjection
293
232
  };
294
233
 
295
- module.exports = DOMProperty;
234
+ module.exports = DOMProperty;