react 0.14.0-beta2 → 0.14.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 (89) hide show
  1. package/README.md +4 -4
  2. package/addons.js +3 -1
  3. package/dist/react-with-addons.js +1944 -1375
  4. package/dist/react-with-addons.min.js +6 -6
  5. package/dist/react.js +1704 -1250
  6. package/dist/react.min.js +6 -6
  7. package/lib/CSSProperty.js +15 -3
  8. package/lib/CSSPropertyOperations.js +15 -2
  9. package/lib/ChangeEventPlugin.js +5 -2
  10. package/lib/DOMChildrenOperations.js +12 -1
  11. package/lib/DOMPropertyOperations.js +14 -1
  12. package/lib/Danger.js +9 -4
  13. package/lib/EnterLeaveEventPlugin.js +13 -5
  14. package/lib/EventConstants.js +2 -2
  15. package/lib/EventPluginHub.js +18 -10
  16. package/lib/EventPluginUtils.js +23 -27
  17. package/lib/EventPropagators.js +1 -1
  18. package/lib/FallbackCompositionState.js +6 -0
  19. package/lib/HTMLDOMPropertyConfig.js +25 -2
  20. package/lib/PooledClass.js +1 -3
  21. package/lib/React.js +14 -3
  22. package/lib/ReactBrowserComponentMixin.js +1 -1
  23. package/lib/ReactBrowserEventEmitter.js +10 -4
  24. package/lib/ReactCSSTransitionGroup.js +33 -18
  25. package/lib/ReactCSSTransitionGroupChild.js +42 -25
  26. package/lib/ReactChildReconciler.js +3 -5
  27. package/lib/ReactChildren.js +70 -30
  28. package/lib/ReactClass.js +6 -6
  29. package/lib/ReactComponent.js +7 -6
  30. package/lib/ReactCompositeComponent.js +58 -7
  31. package/lib/ReactDOM.js +7 -5
  32. package/lib/ReactDOMComponent.js +140 -46
  33. package/lib/ReactDOMFeatureFlags.js +18 -0
  34. package/lib/ReactDOMIDOperations.js +1 -60
  35. package/lib/ReactDOMInput.js +10 -1
  36. package/lib/ReactDOMSelect.js +1 -1
  37. package/lib/ReactDOMSelection.js +16 -0
  38. package/lib/ReactDOMServer.js +3 -1
  39. package/lib/ReactDOMTextComponent.js +23 -10
  40. package/lib/ReactDOMTextarea.js +3 -1
  41. package/lib/ReactDefaultInjection.js +0 -2
  42. package/lib/ReactDefaultPerf.js +10 -4
  43. package/lib/ReactDefaultPerfAnalysis.js +7 -3
  44. package/lib/ReactElement.js +72 -35
  45. package/lib/ReactElementValidator.js +31 -75
  46. package/lib/ReactEmptyComponent.js +25 -61
  47. package/lib/ReactEmptyComponentRegistry.js +48 -0
  48. package/lib/ReactErrorUtils.js +55 -9
  49. package/lib/ReactEventEmitterMixin.js +1 -1
  50. package/lib/ReactEventListener.js +16 -9
  51. package/lib/ReactFragment.js +25 -116
  52. package/lib/ReactInjection.js +0 -2
  53. package/lib/ReactIsomorphic.js +4 -0
  54. package/lib/ReactLink.js +1 -1
  55. package/lib/ReactMount.js +127 -41
  56. package/lib/ReactMultiChild.js +37 -4
  57. package/lib/ReactOwner.js +2 -2
  58. package/lib/ReactPropTransferer.js +1 -1
  59. package/lib/ReactPropTypes.js +11 -8
  60. package/lib/ReactReconcileTransaction.js +4 -2
  61. package/lib/ReactReconciler.js +16 -17
  62. package/lib/ReactRef.js +13 -1
  63. package/lib/ReactServerRenderingTransaction.js +1 -0
  64. package/lib/ReactTestUtils.js +27 -15
  65. package/lib/ReactTransitionChildMapping.js +3 -6
  66. package/lib/ReactUpdateQueue.js +4 -4
  67. package/lib/ReactUpdates.js +1 -1
  68. package/lib/ReactVersion.js +14 -0
  69. package/lib/ReactWithAddons.js +10 -1
  70. package/lib/ResponderEventPlugin.js +1 -1
  71. package/lib/SelectEventPlugin.js +11 -1
  72. package/lib/SimpleEventPlugin.js +10 -31
  73. package/lib/SyntheticEvent.js +15 -1
  74. package/lib/Transaction.js +1 -1
  75. package/lib/canDefineProperty.js +24 -0
  76. package/lib/createHierarchyRenderer.js +1 -1
  77. package/lib/deprecated.js +3 -2
  78. package/lib/findDOMNode.js +1 -1
  79. package/lib/getTestDocument.js +4 -11
  80. package/lib/instantiateReactComponent.js +3 -5
  81. package/lib/reactComponentExpect.js +6 -0
  82. package/lib/shouldUpdateReactComponent.js +12 -8
  83. package/lib/sliceChildren.js +3 -20
  84. package/lib/traverseAllChildren.js +15 -9
  85. package/package.json +2 -2
  86. package/react.js +1 -51
  87. package/dist/JSXTransformer.js +0 -17949
  88. package/lib/joinClasses.js +0 -39
  89. package/lib/memoizeStringOnly.js +0 -31
@@ -64,7 +64,7 @@ function ReactUpdatesFlushTransaction() {
64
64
  this.reinitializeTransaction();
65
65
  this.dirtyComponentsLength = null;
66
66
  this.callbackQueue = CallbackQueue.getPooled();
67
- this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled();
67
+ this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled( /* forceHTML */false);
68
68
  }
69
69
 
70
70
  assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright 2013-2015, 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 ReactVersion
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ module.exports = '0.14.1';
@@ -29,6 +29,9 @@ var ReactUpdates = require('./ReactUpdates');
29
29
  var cloneWithProps = require('./cloneWithProps');
30
30
  var shallowCompare = require('./shallowCompare');
31
31
  var update = require('./update');
32
+ var warning = require('fbjs/lib/warning');
33
+
34
+ var warnedAboutBatchedUpdates = false;
32
35
 
33
36
  React.addons = {
34
37
  CSSTransitionGroup: ReactCSSTransitionGroup,
@@ -36,7 +39,13 @@ React.addons = {
36
39
  PureRenderMixin: ReactComponentWithPureRenderMixin,
37
40
  TransitionGroup: ReactTransitionGroup,
38
41
 
39
- batchedUpdates: ReactUpdates.batchedUpdates,
42
+ batchedUpdates: function () {
43
+ if (process.env.NODE_ENV !== 'production') {
44
+ process.env.NODE_ENV !== 'production' ? warning(warnedAboutBatchedUpdates, 'React.addons.batchedUpdates is deprecated. Use ' + 'ReactDOM.unstable_batchedUpdates instead.') : undefined;
45
+ warnedAboutBatchedUpdates = true;
46
+ }
47
+ return ReactUpdates.batchedUpdates.apply(this, arguments);
48
+ },
40
49
  cloneWithProps: cloneWithProps,
41
50
  createFragment: ReactFragment.create,
42
51
  shallowCompare: shallowCompare,
@@ -69,7 +69,7 @@ var eventTypes = {
69
69
  /**
70
70
  * On a `scroll`, is it desired that this element become the responder? This
71
71
  * is usually not needed, but should be used to retroactively infer that a
72
- * `touchStart` had occured during momentum scroll. During a momentum scroll,
72
+ * `touchStart` had occurred during momentum scroll. During a momentum scroll,
73
73
  * a touch start will be immediately followed by a scroll event if the view is
74
74
  * currently scrolling.
75
75
  *
@@ -13,6 +13,7 @@
13
13
 
14
14
  var EventConstants = require('./EventConstants');
15
15
  var EventPropagators = require('./EventPropagators');
16
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
16
17
  var ReactInputSelection = require('./ReactInputSelection');
17
18
  var SyntheticEvent = require('./SyntheticEvent');
18
19
 
@@ -23,6 +24,8 @@ var shallowEqual = require('fbjs/lib/shallowEqual');
23
24
 
24
25
  var topLevelTypes = EventConstants.topLevelTypes;
25
26
 
27
+ var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
28
+
26
29
  var eventTypes = {
27
30
  select: {
28
31
  phasedRegistrationNames: {
@@ -167,12 +170,19 @@ var SelectEventPlugin = {
167
170
  return constructSelectEvent(nativeEvent, nativeEventTarget);
168
171
 
169
172
  // Chrome and IE fire non-standard event when selection is changed (and
170
- // sometimes when it hasn't).
173
+ // sometimes when it hasn't). IE's event fires out of order with respect
174
+ // to key and input events on deletion, so we discard it.
175
+ //
171
176
  // Firefox doesn't support selectionchange, so check selection status
172
177
  // after each key entry. The selection changes after keydown and before
173
178
  // keyup, but we check on keydown as well in the case of holding down a
174
179
  // key, when multiple keydown events are fired but only one keyup is.
180
+ // This is also our approach for IE handling, for the reason above.
175
181
  case topLevelTypes.topSelectionChange:
182
+ if (skipSelectionChangeEvent) {
183
+ break;
184
+ }
185
+ // falls through
176
186
  case topLevelTypes.topKeyDown:
177
187
  case topLevelTypes.topKeyUp:
178
188
  return constructSelectEvent(nativeEvent, nativeEventTarget);
@@ -13,7 +13,6 @@
13
13
 
14
14
  var EventConstants = require('./EventConstants');
15
15
  var EventListener = require('fbjs/lib/EventListener');
16
- var EventPluginUtils = require('./EventPluginUtils');
17
16
  var EventPropagators = require('./EventPropagators');
18
17
  var ReactMount = require('./ReactMount');
19
18
  var SyntheticClipboardEvent = require('./SyntheticClipboardEvent');
@@ -30,7 +29,6 @@ var emptyFunction = require('fbjs/lib/emptyFunction');
30
29
  var getEventCharCode = require('./getEventCharCode');
31
30
  var invariant = require('fbjs/lib/invariant');
32
31
  var keyOf = require('fbjs/lib/keyOf');
33
- var warning = require('fbjs/lib/warning');
34
32
 
35
33
  var topLevelTypes = EventConstants.topLevelTypes;
36
34
 
@@ -149,6 +147,12 @@ var eventTypes = {
149
147
  captured: keyOf({ onEmptiedCapture: true })
150
148
  }
151
149
  },
150
+ encrypted: {
151
+ phasedRegistrationNames: {
152
+ bubbled: keyOf({ onEncrypted: true }),
153
+ captured: keyOf({ onEncryptedCapture: true })
154
+ }
155
+ },
152
156
  ended: {
153
157
  phasedRegistrationNames: {
154
158
  bubbled: keyOf({ onEnded: true }),
@@ -247,12 +251,6 @@ var eventTypes = {
247
251
  captured: keyOf({ onMouseUpCapture: true })
248
252
  }
249
253
  },
250
- onEncrypted: {
251
- phasedRegistrationNames: {
252
- bubbled: keyOf({ onEncrypted: true }),
253
- captured: keyOf({ onEncryptedCapture: true })
254
- }
255
- },
256
254
  paste: {
257
255
  phasedRegistrationNames: {
258
256
  bubbled: keyOf({ onPaste: true }),
@@ -401,6 +399,7 @@ var topLevelEventsToDispatchConfig = {
401
399
  topDrop: eventTypes.drop,
402
400
  topDurationChange: eventTypes.durationChange,
403
401
  topEmptied: eventTypes.emptied,
402
+ topEncrypted: eventTypes.encrypted,
404
403
  topEnded: eventTypes.ended,
405
404
  topError: eventTypes.error,
406
405
  topFocus: eventTypes.focus,
@@ -417,17 +416,16 @@ var topLevelEventsToDispatchConfig = {
417
416
  topMouseOut: eventTypes.mouseOut,
418
417
  topMouseOver: eventTypes.mouseOver,
419
418
  topMouseUp: eventTypes.mouseUp,
420
- topOnEncrypted: eventTypes.onEncrypted,
421
- topPause: eventTypes.pause,
422
419
  topPaste: eventTypes.paste,
420
+ topPause: eventTypes.pause,
423
421
  topPlay: eventTypes.play,
424
422
  topPlaying: eventTypes.playing,
425
423
  topProgress: eventTypes.progress,
426
424
  topRateChange: eventTypes.rateChange,
427
425
  topReset: eventTypes.reset,
426
+ topScroll: eventTypes.scroll,
428
427
  topSeeked: eventTypes.seeked,
429
428
  topSeeking: eventTypes.seeking,
430
- topScroll: eventTypes.scroll,
431
429
  topStalled: eventTypes.stalled,
432
430
  topSubmit: eventTypes.submit,
433
431
  topSuspend: eventTypes.suspend,
@@ -452,25 +450,6 @@ var SimpleEventPlugin = {
452
450
 
453
451
  eventTypes: eventTypes,
454
452
 
455
- /**
456
- * Same as the default implementation, except cancels the event when return
457
- * value is false. This behavior will be disabled in a future release.
458
- *
459
- * @param {object} event Event to be dispatched.
460
- * @param {function} listener Application-level callback.
461
- * @param {string} domID DOM ID to pass to the callback.
462
- */
463
- executeDispatch: function (event, listener, domID) {
464
- var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
465
-
466
- process.env.NODE_ENV !== 'production' ? warning(typeof returnValue !== 'boolean', 'Returning `false` from an event handler is deprecated and will be ' + 'ignored in a future release. Instead, manually call ' + 'e.stopPropagation() or e.preventDefault(), as appropriate.') : undefined;
467
-
468
- if (returnValue === false) {
469
- event.stopPropagation();
470
- event.preventDefault();
471
- }
472
- },
473
-
474
453
  /**
475
454
  * @param {string} topLevelType Record from `EventConstants`.
476
455
  * @param {DOMEventTarget} topLevelTarget The listening component root node.
@@ -491,6 +470,7 @@ var SimpleEventPlugin = {
491
470
  case topLevelTypes.topCanPlayThrough:
492
471
  case topLevelTypes.topDurationChange:
493
472
  case topLevelTypes.topEmptied:
473
+ case topLevelTypes.topEncrypted:
494
474
  case topLevelTypes.topEnded:
495
475
  case topLevelTypes.topError:
496
476
  case topLevelTypes.topInput:
@@ -498,7 +478,6 @@ var SimpleEventPlugin = {
498
478
  case topLevelTypes.topLoadedData:
499
479
  case topLevelTypes.topLoadedMetadata:
500
480
  case topLevelTypes.topLoadStart:
501
- case topLevelTypes.topOnEncrypted:
502
481
  case topLevelTypes.topPause:
503
482
  case topLevelTypes.topPlay:
504
483
  case topLevelTypes.topPlaying:
@@ -16,13 +16,13 @@ var PooledClass = require('./PooledClass');
16
16
 
17
17
  var assign = require('./Object.assign');
18
18
  var emptyFunction = require('fbjs/lib/emptyFunction');
19
+ var warning = require('fbjs/lib/warning');
19
20
 
20
21
  /**
21
22
  * @interface Event
22
23
  * @see http://www.w3.org/TR/DOM-Level-3-Events/
23
24
  */
24
25
  var EventInterface = {
25
- path: null,
26
26
  type: null,
27
27
  // currentTarget is set when dispatching; no use in copying it here
28
28
  currentTarget: emptyFunction.thatReturnsNull,
@@ -87,6 +87,13 @@ assign(SyntheticEvent.prototype, {
87
87
  preventDefault: function () {
88
88
  this.defaultPrevented = true;
89
89
  var event = this.nativeEvent;
90
+ if (process.env.NODE_ENV !== 'production') {
91
+ process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `preventDefault` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
92
+ }
93
+ if (!event) {
94
+ return;
95
+ }
96
+
90
97
  if (event.preventDefault) {
91
98
  event.preventDefault();
92
99
  } else {
@@ -97,6 +104,13 @@ assign(SyntheticEvent.prototype, {
97
104
 
98
105
  stopPropagation: function () {
99
106
  var event = this.nativeEvent;
107
+ if (process.env.NODE_ENV !== 'production') {
108
+ process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `stopPropagation` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
109
+ }
110
+ if (!event) {
111
+ return;
112
+ }
113
+
100
114
  if (event.stopPropagation) {
101
115
  event.stopPropagation();
102
116
  } else {
@@ -222,7 +222,7 @@ var Transaction = {
222
222
  Mixin: Mixin,
223
223
 
224
224
  /**
225
- * Token to look for to determine if an error occured.
225
+ * Token to look for to determine if an error occurred.
226
226
  */
227
227
  OBSERVED_ERROR: {}
228
228
 
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright 2013-2015, 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 canDefineProperty
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var canDefineProperty = false;
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ try {
17
+ Object.defineProperty({}, 'x', {});
18
+ canDefineProperty = true;
19
+ } catch (x) {
20
+ // IE will fail on defineProperty
21
+ }
22
+ }
23
+
24
+ module.exports = canDefineProperty;
@@ -33,7 +33,7 @@ var React = require('./React');
33
33
  *
34
34
  * var instances = renderHierarchy(
35
35
  * function(ComponentA[, ComponentB, ComponentC]) {
36
- * React.render(<ComponentA />, ...);
36
+ * ReactDOM.render(<ComponentA />, ...);
37
37
  * })
38
38
  * );
39
39
  * instances[0][0]; // First return value of first render method.
package/lib/deprecated.js CHANGED
@@ -20,11 +20,12 @@ var warning = require('fbjs/lib/warning');
20
20
  *
21
21
  * @param {string} fnName The name of the function
22
22
  * @param {string} newModule The module that fn will exist in
23
+ * @param {string} newPackage The module that fn will exist in
23
24
  * @param {*} ctx The context this forwarded call should run in
24
25
  * @param {function} fn The function to forward on to
25
26
  * @return {function} The function that will warn once and then call fn
26
27
  */
27
- function deprecated(fnName, newModule, ctx, fn) {
28
+ function deprecated(fnName, newModule, newPackage, ctx, fn) {
28
29
  var warned = false;
29
30
  if (process.env.NODE_ENV !== 'production') {
30
31
  var newFn = function () {
@@ -32,7 +33,7 @@ function deprecated(fnName, newModule, ctx, fn) {
32
33
  // Require examples in this string must be split to prevent React's
33
34
  // build tools from mistaking them for real requires.
34
35
  // Otherwise the build tools will attempt to build a '%s' module.
35
- '`require' + '("react").%s` is deprecated. Please use `require' + '("%s").%s` ' + 'instead.', fnName, newModule, fnName) : undefined;
36
+ 'React.%s is deprecated. Please use %s.%s from require' + '(\'%s\') ' + 'instead.', fnName, newModule, fnName, newPackage) : undefined;
36
37
  warned = true;
37
38
  return fn.apply(ctx, arguments);
38
39
  };
@@ -42,7 +42,7 @@ function findDOMNode(componentOrElement) {
42
42
  if (ReactInstanceMap.has(componentOrElement)) {
43
43
  return ReactMount.getNodeFromInstance(componentOrElement);
44
44
  }
45
- !(componentOrElement.render == null || typeof componentOrElement.render !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Component (with keys: %s) contains `render` method ' + 'but is not mounted in the DOM', Object.keys(componentOrElement)) : invariant(false) : undefined;
45
+ !(componentOrElement.render == null || typeof componentOrElement.render !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : invariant(false) : undefined;
46
46
  !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : invariant(false) : undefined;
47
47
  }
48
48
 
@@ -12,17 +12,10 @@
12
12
  'use strict';
13
13
 
14
14
  function getTestDocument(markup) {
15
- var iframe = document.createElement('iframe');
16
- iframe.style.display = 'none';
17
- document.body.appendChild(iframe);
18
-
19
- var testDocument = iframe.contentDocument || iframe.contentWindow.document;
20
- testDocument.open();
21
- testDocument.write(markup || '<!doctype html><html><meta charset=utf-8><title>test doc</title>');
22
- testDocument.close();
23
-
24
- iframe.parentNode.removeChild(iframe);
25
- return testDocument;
15
+ document.open();
16
+ document.write(markup || '<!doctype html><html><meta charset=utf-8><title>test doc</title>');
17
+ document.close();
18
+ return document;
26
19
  }
27
20
 
28
21
  module.exports = getTestDocument;
@@ -58,10 +58,8 @@ function instantiateReactComponent(node) {
58
58
  var instance;
59
59
 
60
60
  if (node === null || node === false) {
61
- node = ReactEmptyComponent.emptyElement;
62
- }
63
-
64
- if (typeof node === 'object') {
61
+ instance = new ReactEmptyComponent(instantiateReactComponent);
62
+ } else if (typeof node === 'object') {
65
63
  var element = node;
66
64
  !(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) : undefined;
67
65
 
@@ -70,7 +68,7 @@ function instantiateReactComponent(node) {
70
68
  instance = ReactNativeComponent.createInternalComponent(element);
71
69
  } else if (isInternalComponentType(element.type)) {
72
70
  // This is temporarily available for custom components that are not string
73
- // represenations. I.e. ART. Once those are updated to use the string
71
+ // representations. I.e. ART. Once those are updated to use the string
74
72
  // representation, we can drop this code path.
75
73
  instance = new element.type(element);
76
74
  } else {
@@ -28,6 +28,7 @@ function reactComponentExpect(instance) {
28
28
  }
29
29
 
30
30
  expect(instance).not.toBeNull();
31
+ expect(instance).not.toBeUndefined();
31
32
 
32
33
  !ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : invariant(false) : undefined;
33
34
  var internalInstance = ReactInstanceMap.get(instance);
@@ -138,6 +139,11 @@ assign(reactComponentExpectInternal.prototype, {
138
139
  return this;
139
140
  },
140
141
 
142
+ toBeEmptyComponent: function () {
143
+ var element = this._instance._currentElement;
144
+ return element === null || element === false;
145
+ },
146
+
141
147
  toBePresent: function () {
142
148
  expect(this.instance()).toBeTruthy();
143
149
  return this;
@@ -24,14 +24,18 @@
24
24
  * @protected
25
25
  */
26
26
  function shouldUpdateReactComponent(prevElement, nextElement) {
27
- if (prevElement != null && nextElement != null) {
28
- var prevType = typeof prevElement;
29
- var nextType = typeof nextElement;
30
- if (prevType === 'string' || prevType === 'number') {
31
- return nextType === 'string' || nextType === 'number';
32
- } else {
33
- return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
34
- }
27
+ var prevEmpty = prevElement === null || prevElement === false;
28
+ var nextEmpty = nextElement === null || nextElement === false;
29
+ if (prevEmpty || nextEmpty) {
30
+ return prevEmpty === nextEmpty;
31
+ }
32
+
33
+ var prevType = typeof prevElement;
34
+ var nextType = typeof nextElement;
35
+ if (prevType === 'string' || prevType === 'number') {
36
+ return nextType === 'string' || nextType === 'number';
37
+ } else {
38
+ return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
35
39
  }
36
40
  return false;
37
41
  }
@@ -11,9 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactFragment = require('./ReactFragment');
15
-
16
- var flattenChildren = require('./flattenChildren');
14
+ var ReactChildren = require('./ReactChildren');
17
15
 
18
16
  /**
19
17
  * Slice children that are typically specified as `props.children`. This version
@@ -29,23 +27,8 @@ function sliceChildren(children, start, end) {
29
27
  return children;
30
28
  }
31
29
 
32
- var slicedChildren = {};
33
- var flattenedMap = flattenChildren(children);
34
- var ii = 0;
35
- for (var key in flattenedMap) {
36
- if (!flattenedMap.hasOwnProperty(key)) {
37
- continue;
38
- }
39
- var child = flattenedMap[key];
40
- if (ii >= start) {
41
- slicedChildren[key] = child;
42
- }
43
- ii++;
44
- if (end != null && ii >= end) {
45
- break;
46
- }
47
- }
48
- return ReactFragment.create(slicedChildren);
30
+ var array = ReactChildren.toArray(children);
31
+ return array.slice(start, end);
49
32
  }
50
33
 
51
34
  module.exports = sliceChildren;