react 15.1.0 → 15.2.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 (109) hide show
  1. package/dist/react-with-addons.js +2034 -1313
  2. package/dist/react-with-addons.min.js +7 -6
  3. package/dist/react.js +1832 -1244
  4. package/dist/react.min.js +6 -6
  5. package/lib/CSSPropertyOperations.js +1 -1
  6. package/lib/CallbackQueue.js +3 -2
  7. package/lib/DOMChildrenOperations.js +9 -9
  8. package/lib/DOMLazyTree.js +3 -2
  9. package/lib/DOMProperty.js +6 -4
  10. package/lib/DOMPropertyOperations.js +17 -3
  11. package/lib/Danger.js +10 -8
  12. package/lib/DisabledInputUtils.js +5 -5
  13. package/lib/EventPluginHub.js +8 -2
  14. package/lib/EventPluginRegistry.js +13 -7
  15. package/lib/EventPluginUtils.js +3 -1
  16. package/lib/HTMLDOMPropertyConfig.js +1 -2
  17. package/lib/LinkedValueUtils.js +5 -3
  18. package/lib/NativeMethodsMixin.js +6 -4
  19. package/lib/PooledClass.js +3 -1
  20. package/lib/React.js +1 -1
  21. package/lib/ReactCSSTransitionGroupChild.js +15 -8
  22. package/lib/ReactChildReconciler.js +15 -6
  23. package/lib/ReactClass.js +14 -13
  24. package/lib/ReactComponent.js +3 -6
  25. package/lib/ReactComponentEnvironment.js +3 -1
  26. package/lib/ReactComponentTreeDevtool.js +94 -16
  27. package/lib/ReactComponentTreeTestUtils.js +87 -0
  28. package/lib/ReactCompositeComponent.js +66 -106
  29. package/lib/ReactDOM.js +2 -2
  30. package/lib/ReactDOMButton.js +2 -2
  31. package/lib/ReactDOMComponent.js +130 -76
  32. package/lib/ReactDOMComponentTree.js +23 -21
  33. package/lib/ReactDOMDebugTool.js +7 -1
  34. package/lib/ReactDOMEmptyComponent.js +9 -9
  35. package/lib/ReactDOMFactories.js +1 -1
  36. package/lib/ReactDOMInput.js +52 -16
  37. package/lib/ReactDOMOption.js +40 -26
  38. package/lib/ReactDOMSelect.js +3 -3
  39. package/lib/ReactDOMTextComponent.js +21 -20
  40. package/lib/ReactDOMTextarea.js +59 -32
  41. package/lib/ReactDOMTreeTraversal.js +18 -16
  42. package/lib/ReactDOMUnknownPropertyDevtool.js +41 -15
  43. package/lib/ReactDebugTool.js +88 -27
  44. package/lib/ReactDefaultInjection.js +2 -2
  45. package/lib/ReactElement.js +64 -25
  46. package/lib/ReactElementValidator.js +26 -81
  47. package/lib/ReactEventListener.js +2 -2
  48. package/lib/ReactFragment.js +3 -1
  49. package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
  50. package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +5 -5
  51. package/lib/ReactInjection.js +2 -2
  52. package/lib/ReactInstanceHandles.js +8 -6
  53. package/lib/ReactMount.js +24 -16
  54. package/lib/ReactMultiChild.js +31 -9
  55. package/lib/ReactNativeAttributePayload.js +5 -2
  56. package/lib/ReactNativeBaseComponent.js +7 -7
  57. package/lib/ReactNativeBridgeEventPlugin.js +1 -1
  58. package/lib/ReactNativeComponentTree.js +8 -6
  59. package/lib/ReactNativeDOMIDOperations.js +1 -2
  60. package/lib/ReactNativeDefaultInjection.js +9 -7
  61. package/lib/ReactNativeGlobalResponderHandler.js +1 -1
  62. package/lib/ReactNativeMount.js +1 -1
  63. package/lib/ReactNativeTagHandles.js +3 -1
  64. package/lib/ReactNativeTextComponent.js +10 -9
  65. package/lib/ReactNativeTreeTraversal.js +11 -11
  66. package/lib/ReactNodeTypes.js +5 -3
  67. package/lib/ReactNoop.js +76 -0
  68. package/lib/ReactOwner.js +4 -2
  69. package/lib/ReactPerf.js +83 -7
  70. package/lib/ReactPropTypes.js +23 -0
  71. package/lib/ReactReconcileTransaction.js +1 -1
  72. package/lib/ReactReconciler.js +12 -7
  73. package/lib/ReactServerRendering.js +4 -2
  74. package/lib/ReactSimpleEmptyComponent.js +4 -4
  75. package/lib/ReactTestMount.js +126 -0
  76. package/lib/ReactTestReconcileTransaction.js +100 -0
  77. package/lib/ReactTestRenderer.js +133 -0
  78. package/lib/ReactTestUtils.js +17 -10
  79. package/lib/ReactTransitionChildMapping.js +7 -1
  80. package/lib/ReactTransitionGroup.js +40 -6
  81. package/lib/ReactUpdateQueue.js +9 -1
  82. package/lib/ReactUpdates.js +9 -8
  83. package/lib/ReactVersion.js +1 -1
  84. package/lib/ResponderEventPlugin.js +8 -6
  85. package/lib/ResponderTouchHistoryStore.js +6 -4
  86. package/lib/SimpleEventPlugin.js +3 -1
  87. package/lib/SyntheticEvent.js +2 -3
  88. package/lib/SyntheticUIEvent.js +1 -1
  89. package/lib/Transaction.js +4 -2
  90. package/lib/accumulate.js +3 -1
  91. package/lib/accumulateInto.js +3 -1
  92. package/lib/checkReactTypeSpec.js +71 -0
  93. package/lib/createReactNativeComponentClass.js +2 -2
  94. package/lib/dangerousStyleValue.js +3 -1
  95. package/lib/escapeTextContentForBrowser.js +96 -12
  96. package/lib/findDOMNode.js +6 -4
  97. package/lib/findNodeHandle.js +5 -3
  98. package/lib/flattenChildren.js +13 -4
  99. package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
  100. package/lib/instantiateReactComponent.js +13 -12
  101. package/lib/onlyChild.js +3 -1
  102. package/lib/reactComponentExpect.js +3 -3
  103. package/lib/reactProdInvariant.js +38 -0
  104. package/lib/setInnerHTML.js +17 -1
  105. package/lib/setTextContent.js +8 -0
  106. package/lib/traverseAllChildren.js +3 -1
  107. package/lib/update.js +12 -11
  108. package/package.json +2 -2
  109. package/lib/MetaMatchers.js +0 -118
@@ -19,9 +19,9 @@ var ReactNativeComponentTree = require('./ReactNativeComponentTree');
19
19
  var ReactNativeEventEmitter = require('./ReactNativeEventEmitter');
20
20
  var ReactNativeTagHandles = require('./ReactNativeTagHandles');
21
21
  var ReactMultiChild = require('./ReactMultiChild');
22
- var UIManager = require('UIManager');
22
+ var UIManager = require('react-native/lib/UIManager');
23
23
 
24
- var deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev');
24
+ var deepFreezeAndThrowOnMutationInDev = require('react-native/lib/deepFreezeAndThrowOnMutationInDev');
25
25
 
26
26
  var registrationNames = ReactNativeEventEmitter.registrationNames;
27
27
  var putListener = ReactNativeEventEmitter.putListener;
@@ -150,7 +150,7 @@ ReactNativeBaseComponent.Mixin = {
150
150
  *
151
151
  * @return {null} Null.
152
152
  */
153
- getNativeNode: function () {
153
+ getHostNode: function () {
154
154
  return this._rootNodeID;
155
155
  },
156
156
 
@@ -159,12 +159,12 @@ ReactNativeBaseComponent.Mixin = {
159
159
  * @param {Transaction} transaction For creating/updating.
160
160
  * @return {string} Unique iOS view tag.
161
161
  */
162
- mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
162
+ mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
163
163
  var tag = ReactNativeTagHandles.allocateTag();
164
164
 
165
165
  this._rootNodeID = tag;
166
- this._nativeParent = nativeParent;
167
- this._nativeContainerInfo = nativeContainerInfo;
166
+ this._hostParent = hostParent;
167
+ this._hostContainerInfo = hostContainerInfo;
168
168
 
169
169
  if (process.env.NODE_ENV !== 'production') {
170
170
  for (var key in this.viewConfig.validAttributes) {
@@ -176,7 +176,7 @@ ReactNativeBaseComponent.Mixin = {
176
176
 
177
177
  var updatePayload = ReactNativeAttributePayload.create(this._currentElement.props, this.viewConfig.validAttributes);
178
178
 
179
- var nativeTopRootTag = nativeContainerInfo._tag;
179
+ var nativeTopRootTag = hostContainerInfo._tag;
180
180
  UIManager.createView(tag, this.viewConfig.uiViewClassName, nativeTopRootTag, updatePayload);
181
181
 
182
182
  ReactNativeComponentTree.precacheNode(this, tag);
@@ -17,7 +17,7 @@ var _extends = _assign || function (target) { for (var i = 1; i < arguments.leng
17
17
 
18
18
  var EventPropagators = require('./EventPropagators');
19
19
  var SyntheticEvent = require('./SyntheticEvent');
20
- var UIManager = require('UIManager');
20
+ var UIManager = require('react-native/lib/UIManager');
21
21
 
22
22
  var warning = require('fbjs/lib/warning');
23
23
 
@@ -11,18 +11,20 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var invariant = require('fbjs/lib/invariant');
15
17
 
16
18
  var instanceCache = {};
17
19
 
18
20
  /**
19
- * Drill down (through composites and empty components) until we get a native or
20
- * native text component.
21
+ * Drill down (through composites and empty components) until we get a host or
22
+ * host text component.
21
23
  *
22
24
  * This is pretty polymorphic but unavoidable with the current structure we have
23
25
  * for `_renderedChildren`.
24
26
  */
25
- function getRenderedNativeOrTextFromComponent(component) {
27
+ function getRenderedHostOrTextFromComponent(component) {
26
28
  var rendered;
27
29
  while (rendered = component._renderedComponent) {
28
30
  component = rendered;
@@ -31,11 +33,11 @@ function getRenderedNativeOrTextFromComponent(component) {
31
33
  }
32
34
 
33
35
  /**
34
- * Populate `_nativeNode` on the rendered native/text component with the given
36
+ * Populate `_hostNode` on the rendered host/text component with the given
35
37
  * DOM node. The passed `inst` can be a composite.
36
38
  */
37
39
  function precacheNode(inst, tag) {
38
- var nativeInst = getRenderedNativeOrTextFromComponent(inst);
40
+ var nativeInst = getRenderedHostOrTextFromComponent(inst);
39
41
  instanceCache[tag] = nativeInst;
40
42
  }
41
43
 
@@ -51,7 +53,7 @@ function getInstanceFromTag(tag) {
51
53
  }
52
54
 
53
55
  function getTagFromInstance(inst) {
54
- !inst._rootNodeID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'All native instances should have a tag.') : invariant(false) : void 0;
56
+ !inst._rootNodeID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'All native instances should have a tag.') : _prodInvariant('17') : void 0;
55
57
  return inst._rootNodeID;
56
58
  }
57
59
 
@@ -7,13 +7,12 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactNativeDOMIDOperations
10
- *
11
10
  */
12
11
  'use strict';
13
12
 
14
13
  var ReactNativeComponentTree = require('./ReactNativeComponentTree');
15
14
  var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
16
- var UIManager = require('UIManager');
15
+ var UIManager = require('react-native/lib/UIManager');
17
16
 
18
17
  /**
19
18
  * Updates a component's children by processing a series of updates.
@@ -18,17 +18,19 @@
18
18
  * TODO: require this in packager, not in React #10932517
19
19
  */
20
20
 
21
- require('InitializeJavaScriptAppEngine');
21
+ var _prodInvariant = require('./reactProdInvariant');
22
+
23
+ require('react-native/lib/InitializeJavaScriptAppEngine');
22
24
 
23
25
  var EventPluginHub = require('./EventPluginHub');
24
26
  var EventPluginUtils = require('./EventPluginUtils');
25
- var RCTEventEmitter = require('RCTEventEmitter');
27
+ var RCTEventEmitter = require('react-native/lib/RCTEventEmitter');
26
28
  var ReactComponentEnvironment = require('./ReactComponentEnvironment');
27
29
  var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
28
30
  var ReactElement = require('./ReactElement');
29
31
  var ReactEmptyComponent = require('./ReactEmptyComponent');
30
32
  var ReactNativeBridgeEventPlugin = require('./ReactNativeBridgeEventPlugin');
31
- var ReactNativeComponent = require('./ReactNativeComponent');
33
+ var ReactHostComponent = require('./ReactHostComponent');
32
34
  var ReactNativeComponentEnvironment = require('./ReactNativeComponentEnvironment');
33
35
  var ReactNativeComponentTree = require('./ReactNativeComponentTree');
34
36
  var ReactNativeEventEmitter = require('./ReactNativeEventEmitter');
@@ -74,7 +76,7 @@ function inject() {
74
76
 
75
77
  var EmptyComponent = function (instantiate) {
76
78
  // Can't import View at the top because it depends on React to make its composite
77
- var View = require('View');
79
+ var View = require('react-native/lib/View');
78
80
  return new ReactSimpleEmptyComponent(ReactElement.createElement(View, {
79
81
  collapsable: true,
80
82
  style: { position: 'absolute' }
@@ -83,14 +85,14 @@ function inject() {
83
85
 
84
86
  ReactEmptyComponent.injection.injectEmptyComponentFactory(EmptyComponent);
85
87
 
86
- ReactNativeComponent.injection.injectTextComponentClass(ReactNativeTextComponent);
87
- ReactNativeComponent.injection.injectGenericComponentClass(function (tag) {
88
+ ReactHostComponent.injection.injectTextComponentClass(ReactNativeTextComponent);
89
+ ReactHostComponent.injection.injectGenericComponentClass(function (tag) {
88
90
  // Show a nicer error message for non-function tags
89
91
  var info = '';
90
92
  if (typeof tag === 'string' && /^[a-z]/.test(tag)) {
91
93
  info += ' Each component name should start with an uppercase letter.';
92
94
  }
93
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected a component class, got %s.%s', tag, info) : invariant(false) : void 0;
95
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected a component class, got %s.%s', tag, info) : _prodInvariant('18', tag, info) : void 0;
94
96
  });
95
97
  }
96
98
 
@@ -10,7 +10,7 @@
10
10
  */
11
11
  'use strict';
12
12
 
13
- var UIManager = require('UIManager');
13
+ var UIManager = require('react-native/lib/UIManager');
14
14
 
15
15
  var ReactNativeGlobalResponderHandler = {
16
16
  onChange: function (from, to, blockNativeResponder) {
@@ -18,7 +18,7 @@ var ReactNativeTagHandles = require('./ReactNativeTagHandles');
18
18
  var ReactReconciler = require('./ReactReconciler');
19
19
  var ReactUpdateQueue = require('./ReactUpdateQueue');
20
20
  var ReactUpdates = require('./ReactUpdates');
21
- var UIManager = require('UIManager');
21
+ var UIManager = require('react-native/lib/UIManager');
22
22
 
23
23
  var emptyObject = require('fbjs/lib/emptyObject');
24
24
  var instantiateReactComponent = require('./instantiateReactComponent');
@@ -11,6 +11,8 @@
11
11
  */
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var invariant = require('fbjs/lib/invariant');
15
17
 
16
18
  /**
@@ -42,7 +44,7 @@ var ReactNativeTagHandles = {
42
44
  },
43
45
 
44
46
  assertRootTag: function (tag) {
45
- !this.reactTagIsNativeTopRootID(tag) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expect a native root tag, instead got %s', tag) : invariant(false) : void 0;
47
+ !this.reactTagIsNativeTopRootID(tag) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expect a native root tag, instead got %s', tag) : _prodInvariant('19', tag) : void 0;
46
48
  },
47
49
 
48
50
  reactTagIsNativeTopRootID: function (reactTag) {
@@ -11,12 +11,13 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var _assign = require('object-assign');
14
+ var _prodInvariant = require('./reactProdInvariant'),
15
+ _assign = require('object-assign');
15
16
 
16
17
  var ReactInstrumentation = require('./ReactInstrumentation');
17
18
  var ReactNativeComponentTree = require('./ReactNativeComponentTree');
18
19
  var ReactNativeTagHandles = require('./ReactNativeTagHandles');
19
- var UIManager = require('UIManager');
20
+ var UIManager = require('react-native/lib/UIManager');
20
21
 
21
22
  var invariant = require('fbjs/lib/invariant');
22
23
 
@@ -24,23 +25,23 @@ var ReactNativeTextComponent = function (text) {
24
25
  // This is really a ReactText (ReactNode), not a ReactElement
25
26
  this._currentElement = text;
26
27
  this._stringText = '' + text;
27
- this._nativeParent = null;
28
+ this._hostParent = null;
28
29
  this._rootNodeID = null;
29
30
  };
30
31
 
31
32
  _assign(ReactNativeTextComponent.prototype, {
32
33
 
33
- mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
34
+ mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
34
35
  if (process.env.NODE_ENV !== 'production') {
35
36
  ReactInstrumentation.debugTool.onSetText(this._debugID, this._stringText);
36
37
  }
37
38
 
38
- // TODO: nativeParent should have this context already. Stop abusing context.
39
- !context.isInAParentText ? process.env.NODE_ENV !== 'production' ? invariant(false, 'RawText "%s" must be wrapped in an explicit <Text> component.', this._stringText) : invariant(false) : void 0;
40
- this._nativeParent = nativeParent;
39
+ // TODO: hostParent should have this context already. Stop abusing context.
40
+ !context.isInAParentText ? process.env.NODE_ENV !== 'production' ? invariant(false, 'RawText "%s" must be wrapped in an explicit <Text> component.', this._stringText) : _prodInvariant('20', this._stringText) : void 0;
41
+ this._hostParent = hostParent;
41
42
  var tag = ReactNativeTagHandles.allocateTag();
42
43
  this._rootNodeID = tag;
43
- var nativeTopRootTag = nativeContainerInfo._tag;
44
+ var nativeTopRootTag = hostContainerInfo._tag;
44
45
  UIManager.createView(tag, 'RCTRawText', nativeTopRootTag, { text: this._stringText });
45
46
 
46
47
  ReactNativeComponentTree.precacheNode(this, tag);
@@ -48,7 +49,7 @@ _assign(ReactNativeTextComponent.prototype, {
48
49
  return tag;
49
50
  },
50
51
 
51
- getNativeNode: function () {
52
+ getHostNode: function () {
52
53
  return this._rootNodeID;
53
54
  },
54
55
 
@@ -20,23 +20,23 @@
20
20
 
21
21
  function getLowestCommonAncestor(instA, instB) {
22
22
  var depthA = 0;
23
- for (var tempA = instA; tempA; tempA = tempA._nativeParent) {
23
+ for (var tempA = instA; tempA; tempA = tempA._hostParent) {
24
24
  depthA++;
25
25
  }
26
26
  var depthB = 0;
27
- for (var tempB = instB; tempB; tempB = tempB._nativeParent) {
27
+ for (var tempB = instB; tempB; tempB = tempB._hostParent) {
28
28
  depthB++;
29
29
  }
30
30
 
31
31
  // If A is deeper, crawl up.
32
32
  while (depthA - depthB > 0) {
33
- instA = instA._nativeParent;
33
+ instA = instA._hostParent;
34
34
  depthA--;
35
35
  }
36
36
 
37
37
  // If B is deeper, crawl up.
38
38
  while (depthB - depthA > 0) {
39
- instB = instB._nativeParent;
39
+ instB = instB._hostParent;
40
40
  depthB--;
41
41
  }
42
42
 
@@ -46,8 +46,8 @@ function getLowestCommonAncestor(instA, instB) {
46
46
  if (instA === instB) {
47
47
  return instA;
48
48
  }
49
- instA = instA._nativeParent;
50
- instB = instB._nativeParent;
49
+ instA = instA._hostParent;
50
+ instB = instB._hostParent;
51
51
  }
52
52
  return null;
53
53
  }
@@ -60,7 +60,7 @@ function isAncestor(instA, instB) {
60
60
  if (instB === instA) {
61
61
  return true;
62
62
  }
63
- instB = instB._nativeParent;
63
+ instB = instB._hostParent;
64
64
  }
65
65
  return false;
66
66
  }
@@ -69,7 +69,7 @@ function isAncestor(instA, instB) {
69
69
  * Return the parent instance of the passed-in instance.
70
70
  */
71
71
  function getParentInstance(inst) {
72
- return inst._nativeParent;
72
+ return inst._hostParent;
73
73
  }
74
74
 
75
75
  /**
@@ -79,7 +79,7 @@ function traverseTwoPhase(inst, fn, arg) {
79
79
  var path = [];
80
80
  while (inst) {
81
81
  path.push(inst);
82
- inst = inst._nativeParent;
82
+ inst = inst._hostParent;
83
83
  }
84
84
  var i;
85
85
  for (i = path.length; i-- > 0;) {
@@ -102,12 +102,12 @@ function traverseEnterLeave(from, to, fn, argFrom, argTo) {
102
102
  var pathFrom = [];
103
103
  while (from && from !== common) {
104
104
  pathFrom.push(from);
105
- from = from._nativeParent;
105
+ from = from._hostParent;
106
106
  }
107
107
  var pathTo = [];
108
108
  while (to && to !== common) {
109
109
  pathTo.push(to);
110
- to = to._nativeParent;
110
+ to = to._hostParent;
111
111
  }
112
112
  var i;
113
113
  for (i = 0; i < pathFrom.length; i++) {
@@ -11,12 +11,14 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var ReactElement = require('./ReactElement');
15
17
 
16
18
  var invariant = require('fbjs/lib/invariant');
17
19
 
18
20
  var ReactNodeTypes = {
19
- NATIVE: 0,
21
+ HOST: 0,
20
22
  COMPOSITE: 1,
21
23
  EMPTY: 2,
22
24
 
@@ -27,10 +29,10 @@ var ReactNodeTypes = {
27
29
  if (typeof node.type === 'function') {
28
30
  return ReactNodeTypes.COMPOSITE;
29
31
  } else {
30
- return ReactNodeTypes.NATIVE;
32
+ return ReactNodeTypes.HOST;
31
33
  }
32
34
  }
33
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unexpected node: %s', node) : invariant(false) : void 0;
35
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unexpected node: %s', node) : _prodInvariant('26', node) : void 0;
34
36
  }
35
37
  };
36
38
 
@@ -0,0 +1,76 @@
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 ReactNoop
10
+ *
11
+ */
12
+
13
+ /**
14
+ * This is a renderer of React that doesn't have a render target output.
15
+ * It is useful to demonstrate the internals of the reconciler in isolation
16
+ * and for testing semantics of reconciliation separate from the host
17
+ * environment.
18
+ */
19
+
20
+ 'use strict';
21
+
22
+ var ReactFiberReconciler = require('./ReactFiberReconciler');
23
+
24
+ var scheduledHighPriCallback = null;
25
+ var scheduledLowPriCallback = null;
26
+
27
+ var NoopRenderer = ReactFiberReconciler({
28
+ createHostInstance: function () {},
29
+ scheduleHighPriCallback: function (callback) {
30
+ scheduledHighPriCallback = callback;
31
+ },
32
+ scheduleLowPriCallback: function (callback) {
33
+ scheduledLowPriCallback = callback;
34
+ }
35
+ });
36
+
37
+ var ReactNoop = {
38
+ render: function (element) {
39
+
40
+ NoopRenderer.mountNewRoot(element);
41
+ },
42
+ flushHighPri: function () {
43
+ var cb = scheduledHighPriCallback;
44
+ if (cb === null) {
45
+ return;
46
+ }
47
+ scheduledHighPriCallback = null;
48
+ cb();
49
+ },
50
+ flushLowPri: function () {
51
+ var timeout = arguments.length <= 0 || arguments[0] === undefined ? Infinity : arguments[0];
52
+
53
+ var cb = scheduledLowPriCallback;
54
+ if (cb === null) {
55
+ return;
56
+ }
57
+ scheduledLowPriCallback = null;
58
+ var timeRemaining = timeout;
59
+ cb({
60
+ timeRemaining: function () {
61
+ // Simulate a fix amount of time progressing between each call.
62
+ timeRemaining -= 5;
63
+ if (timeRemaining < 0) {
64
+ timeRemaining = 0;
65
+ }
66
+ return timeRemaining;
67
+ }
68
+ });
69
+ },
70
+ flush: function () {
71
+ ReactNoop.flushHighPri();
72
+ ReactNoop.flushLowPri();
73
+ }
74
+ };
75
+
76
+ module.exports = ReactNoop;