react 15.1.0 → 15.2.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.
- package/dist/react-with-addons.js +2685 -1842
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +2400 -1691
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/CallbackQueue.js +3 -2
- package/lib/DOMChildrenOperations.js +9 -9
- package/lib/DOMLazyTree.js +3 -2
- package/lib/DOMProperty.js +5 -12
- package/lib/DOMPropertyOperations.js +21 -15
- package/lib/Danger.js +5 -101
- package/lib/DisabledInputUtils.js +5 -5
- package/lib/EventPluginHub.js +8 -2
- package/lib/EventPluginRegistry.js +13 -7
- package/lib/EventPluginUtils.js +3 -1
- package/lib/HTMLDOMPropertyConfig.js +1 -2
- package/lib/KeyEscapeUtils.js +2 -1
- package/lib/LinkedValueUtils.js +5 -3
- package/lib/NativeMethodsMixin.js +6 -4
- package/lib/PooledClass.js +4 -2
- package/lib/React.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +15 -8
- package/lib/ReactChildReconciler.js +17 -8
- package/lib/ReactClass.js +14 -13
- package/lib/ReactComponent.js +3 -6
- package/lib/ReactComponentEnvironment.js +3 -1
- package/lib/ReactComponentTreeDevtool.js +89 -16
- package/lib/ReactComponentTreeTestUtils.js +87 -0
- package/lib/ReactCompositeComponent.js +87 -117
- package/lib/ReactDOM.js +2 -2
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +130 -76
- package/lib/ReactDOMComponentTree.js +23 -21
- package/lib/ReactDOMDebugTool.js +17 -11
- package/lib/ReactDOMEmptyComponent.js +9 -9
- package/lib/ReactDOMFactories.js +1 -1
- package/lib/ReactDOMFiber.js +78 -0
- package/lib/ReactDOMInput.js +64 -26
- package/lib/ReactDOMInstrumentation.js +7 -2
- package/lib/ReactDOMNullInputValuePropDevtool.js +43 -0
- package/lib/ReactDOMOption.js +40 -26
- package/lib/ReactDOMSelect.js +3 -16
- package/lib/ReactDOMTextComponent.js +21 -20
- package/lib/ReactDOMTextarea.js +59 -46
- package/lib/ReactDOMTreeTraversal.js +18 -16
- package/lib/ReactDOMUnknownPropertyDevtool.js +65 -17
- package/lib/ReactDebugTool.js +148 -95
- package/lib/ReactDefaultInjection.js +2 -2
- package/lib/ReactElement.js +64 -25
- package/lib/ReactElementValidator.js +26 -81
- package/lib/ReactEventListener.js +2 -2
- package/lib/ReactFeatureFlags.js +1 -0
- package/lib/ReactFragment.js +3 -1
- package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
- package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +5 -5
- package/lib/ReactInjection.js +2 -2
- package/lib/ReactInstanceHandles.js +8 -6
- package/lib/ReactInstrumentation.js +7 -2
- package/lib/ReactMount.js +38 -32
- package/lib/ReactMultiChild.js +38 -11
- package/lib/ReactNativeAttributePayload.js +5 -2
- package/lib/ReactNativeBaseComponent.js +7 -7
- package/lib/ReactNativeBridgeEventPlugin.js +1 -1
- package/lib/ReactNativeComponentTree.js +8 -6
- package/lib/ReactNativeDOMIDOperations.js +1 -2
- package/lib/ReactNativeDefaultInjection.js +9 -7
- package/lib/ReactNativeGlobalResponderHandler.js +1 -1
- package/lib/ReactNativeMount.js +3 -14
- package/lib/ReactNativeReconcileTransaction.js +16 -0
- package/lib/ReactNativeTagHandles.js +3 -1
- package/lib/ReactNativeTextComponent.js +10 -9
- package/lib/ReactNativeTreeTraversal.js +11 -11
- package/lib/ReactNodeTypes.js +6 -3
- package/lib/ReactNoop.js +173 -0
- package/lib/ReactNoopUpdateQueue.js +6 -5
- package/lib/ReactOwner.js +4 -2
- package/lib/ReactPerf.js +83 -7
- package/lib/ReactPropTypes.js +23 -0
- package/lib/ReactReconcileTransaction.js +17 -1
- package/lib/ReactReconciler.js +12 -7
- package/lib/ReactServerRendering.js +5 -7
- package/lib/ReactServerRenderingTransaction.js +17 -0
- package/lib/ReactServerUpdateQueue.js +141 -0
- package/lib/ReactSimpleEmptyComponent.js +4 -4
- package/lib/ReactTestMount.js +115 -0
- package/lib/ReactTestReconcileTransaction.js +108 -0
- package/lib/ReactTestRenderer.js +133 -0
- package/lib/ReactTestUtils.js +17 -10
- package/lib/ReactTransitionChildMapping.js +7 -1
- package/lib/ReactTransitionGroup.js +41 -6
- package/lib/ReactUpdateQueue.js +13 -3
- package/lib/ReactUpdates.js +10 -18
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +9 -7
- package/lib/ResponderTouchHistoryStore.js +99 -95
- package/lib/SimpleEventPlugin.js +3 -1
- package/lib/SyntheticEvent.js +2 -3
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/Transaction.js +4 -2
- package/lib/accumulate.js +17 -15
- package/lib/accumulateInto.js +11 -12
- package/lib/adler32.js +1 -0
- package/lib/checkReactTypeSpec.js +73 -0
- package/lib/createReactNativeComponentClass.js +2 -2
- package/lib/dangerousStyleValue.js +3 -1
- package/lib/deprecated.js +7 -1
- package/lib/escapeTextContentForBrowser.js +96 -12
- package/lib/findDOMNode.js +6 -4
- package/lib/findNodeHandle.js +5 -3
- package/lib/flattenChildren.js +22 -10
- package/lib/forEachAccumulated.js +3 -2
- package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
- package/lib/getIteratorFn.js +1 -0
- package/lib/instantiateReactComponent.js +21 -19
- package/lib/isTextInputElement.js +11 -1
- package/lib/onlyChild.js +3 -1
- package/lib/reactComponentExpect.js +3 -3
- package/lib/reactProdInvariant.js +39 -0
- package/lib/setInnerHTML.js +17 -1
- package/lib/setTextContent.js +8 -0
- package/lib/traverseAllChildren.js +3 -1
- package/lib/update.js +12 -11
- package/package.json +2 -2
- package/lib/MetaMatchers.js +0 -118
|
@@ -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
|
|
20
|
-
*
|
|
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
|
|
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 `
|
|
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 =
|
|
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.') :
|
|
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('
|
|
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
|
|
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
|
-
|
|
87
|
-
|
|
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) :
|
|
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
|
|
package/lib/ReactNativeMount.js
CHANGED
|
@@ -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');
|
|
@@ -89,7 +89,7 @@ var ReactNativeMount = {
|
|
|
89
89
|
var prevWrappedElement = prevComponent._currentElement;
|
|
90
90
|
var prevElement = prevWrappedElement.props;
|
|
91
91
|
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
92
|
-
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextWrappedElement);
|
|
92
|
+
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextWrappedElement, emptyObject);
|
|
93
93
|
if (callback) {
|
|
94
94
|
ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
|
|
95
95
|
}
|
|
@@ -106,19 +106,9 @@ var ReactNativeMount = {
|
|
|
106
106
|
|
|
107
107
|
ReactNativeTagHandles.assertRootTag(containerTag);
|
|
108
108
|
|
|
109
|
-
var instance = instantiateReactComponent(nextWrappedElement);
|
|
109
|
+
var instance = instantiateReactComponent(nextWrappedElement, false);
|
|
110
110
|
ReactNativeMount._instancesByContainerID[containerTag] = instance;
|
|
111
111
|
|
|
112
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
113
|
-
// Mute future events from the top level wrapper.
|
|
114
|
-
// It is an implementation detail that devtools should not know about.
|
|
115
|
-
instance._debugID = 0;
|
|
116
|
-
|
|
117
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
118
|
-
ReactInstrumentation.debugTool.onBeginFlush();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
112
|
// The initial render is synchronous but any updates that happen during
|
|
123
113
|
// rendering, in componentWillMount or componentDidMount, will be batched
|
|
124
114
|
// according to the current batching strategy.
|
|
@@ -127,7 +117,6 @@ var ReactNativeMount = {
|
|
|
127
117
|
if (process.env.NODE_ENV !== 'production') {
|
|
128
118
|
// The instance here is TopLevelWrapper so we report mount for its child.
|
|
129
119
|
ReactInstrumentation.debugTool.onMountRootComponent(instance._renderedComponent._debugID);
|
|
130
|
-
ReactInstrumentation.debugTool.onEndFlush();
|
|
131
120
|
}
|
|
132
121
|
var component = instance.getPublicInstance();
|
|
133
122
|
if (callback) {
|
|
@@ -16,6 +16,8 @@ var _assign = require('object-assign');
|
|
|
16
16
|
var CallbackQueue = require('./CallbackQueue');
|
|
17
17
|
var PooledClass = require('./PooledClass');
|
|
18
18
|
var Transaction = require('./Transaction');
|
|
19
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
20
|
+
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks during
|
|
@@ -44,6 +46,13 @@ var ON_DOM_READY_QUEUEING = {
|
|
|
44
46
|
*/
|
|
45
47
|
var TRANSACTION_WRAPPERS = [ON_DOM_READY_QUEUEING];
|
|
46
48
|
|
|
49
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
50
|
+
TRANSACTION_WRAPPERS.push({
|
|
51
|
+
initialize: ReactInstrumentation.debugTool.onBeginFlush,
|
|
52
|
+
close: ReactInstrumentation.debugTool.onEndFlush
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
47
56
|
/**
|
|
48
57
|
* Currently:
|
|
49
58
|
* - The order that these are listed in the transaction is critical:
|
|
@@ -83,6 +92,13 @@ var Mixin = {
|
|
|
83
92
|
return this.reactMountReady;
|
|
84
93
|
},
|
|
85
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @return {object} The queue to collect React async events.
|
|
97
|
+
*/
|
|
98
|
+
getUpdateQueue: function () {
|
|
99
|
+
return ReactUpdateQueue;
|
|
100
|
+
},
|
|
101
|
+
|
|
86
102
|
/**
|
|
87
103
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
88
104
|
* instance to be reused.
|
|
@@ -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) :
|
|
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
|
|
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.
|
|
28
|
+
this._hostParent = null;
|
|
28
29
|
this._rootNodeID = null;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
_assign(ReactNativeTextComponent.prototype, {
|
|
32
33
|
|
|
33
|
-
mountComponent: function (transaction,
|
|
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:
|
|
39
|
-
!context.isInAParentText ? process.env.NODE_ENV !== 'production' ? invariant(false, 'RawText "%s" must be wrapped in an explicit <Text> component.', this._stringText) :
|
|
40
|
-
this.
|
|
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 =
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
50
|
-
instB = instB.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
105
|
+
from = from._hostParent;
|
|
106
106
|
}
|
|
107
107
|
var pathTo = [];
|
|
108
108
|
while (to && to !== common) {
|
|
109
109
|
pathTo.push(to);
|
|
110
|
-
to = to.
|
|
110
|
+
to = to._hostParent;
|
|
111
111
|
}
|
|
112
112
|
var i;
|
|
113
113
|
for (i = 0; i < pathFrom.length; i++) {
|
package/lib/ReactNodeTypes.js
CHANGED
|
@@ -7,16 +7,19 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactNodeTypes
|
|
10
|
+
*
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
'use strict';
|
|
13
14
|
|
|
15
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
16
|
+
|
|
14
17
|
var ReactElement = require('./ReactElement');
|
|
15
18
|
|
|
16
19
|
var invariant = require('fbjs/lib/invariant');
|
|
17
20
|
|
|
18
21
|
var ReactNodeTypes = {
|
|
19
|
-
|
|
22
|
+
HOST: 0,
|
|
20
23
|
COMPOSITE: 1,
|
|
21
24
|
EMPTY: 2,
|
|
22
25
|
|
|
@@ -27,10 +30,10 @@ var ReactNodeTypes = {
|
|
|
27
30
|
if (typeof node.type === 'function') {
|
|
28
31
|
return ReactNodeTypes.COMPOSITE;
|
|
29
32
|
} else {
|
|
30
|
-
return ReactNodeTypes.
|
|
33
|
+
return ReactNodeTypes.HOST;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unexpected node: %s', node) :
|
|
36
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unexpected node: %s', node) : _prodInvariant('26', node) : void 0;
|
|
34
37
|
}
|
|
35
38
|
};
|
|
36
39
|
|
package/lib/ReactNoop.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
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 TERMINAL_TAG = 99;
|
|
28
|
+
|
|
29
|
+
var instanceCounter = 0;
|
|
30
|
+
|
|
31
|
+
function recursivelyAppendChildren(flatArray, child) {
|
|
32
|
+
if (!child) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (child.tag === TERMINAL_TAG) {
|
|
36
|
+
flatArray.push(child);
|
|
37
|
+
} else {
|
|
38
|
+
var node = child;
|
|
39
|
+
do {
|
|
40
|
+
recursivelyAppendChildren(flatArray, node.output);
|
|
41
|
+
} while (node = node.sibling);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function flattenChildren(children) {
|
|
46
|
+
var flatArray = [];
|
|
47
|
+
recursivelyAppendChildren(flatArray, children);
|
|
48
|
+
return flatArray;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var NoopRenderer = ReactFiberReconciler({
|
|
52
|
+
updateContainer: function (containerInfo, children) {
|
|
53
|
+
console.log('Update container #' + containerInfo.rootID);
|
|
54
|
+
containerInfo.children = flattenChildren(children);
|
|
55
|
+
},
|
|
56
|
+
createInstance: function (type, props, children) {
|
|
57
|
+
console.log('Create instance #' + instanceCounter);
|
|
58
|
+
var inst = {
|
|
59
|
+
tag: TERMINAL_TAG,
|
|
60
|
+
id: instanceCounter++,
|
|
61
|
+
type: type,
|
|
62
|
+
children: flattenChildren(children)
|
|
63
|
+
};
|
|
64
|
+
// Hide from unit tests
|
|
65
|
+
Object.defineProperty(inst, 'tag', { value: inst.tag, enumerable: false });
|
|
66
|
+
Object.defineProperty(inst, 'id', { value: inst.id, enumerable: false });
|
|
67
|
+
return inst;
|
|
68
|
+
},
|
|
69
|
+
prepareUpdate: function (instance, oldProps, newProps, children) {
|
|
70
|
+
console.log('Prepare for update on #' + instance.id);
|
|
71
|
+
return true;
|
|
72
|
+
},
|
|
73
|
+
commitUpdate: function (instance, oldProps, newProps, children) {
|
|
74
|
+
console.log('Commit update on #' + instance.id);
|
|
75
|
+
instance.children = flattenChildren(children);
|
|
76
|
+
},
|
|
77
|
+
deleteInstance: function (instance) {
|
|
78
|
+
console.log('Delete #' + instance.id);
|
|
79
|
+
},
|
|
80
|
+
scheduleHighPriCallback: function (callback) {
|
|
81
|
+
scheduledHighPriCallback = callback;
|
|
82
|
+
},
|
|
83
|
+
scheduleLowPriCallback: function (callback) {
|
|
84
|
+
scheduledLowPriCallback = callback;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
var rootContainer = { rootID: 0, children: [] };
|
|
89
|
+
|
|
90
|
+
var root = null;
|
|
91
|
+
|
|
92
|
+
var ReactNoop = {
|
|
93
|
+
|
|
94
|
+
root: rootContainer,
|
|
95
|
+
|
|
96
|
+
render: function (element) {
|
|
97
|
+
if (!root) {
|
|
98
|
+
root = NoopRenderer.mountContainer(element, rootContainer);
|
|
99
|
+
} else {
|
|
100
|
+
NoopRenderer.updateContainer(element, root);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
flushHighPri: function () {
|
|
104
|
+
var cb = scheduledHighPriCallback;
|
|
105
|
+
if (cb === null) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
scheduledHighPriCallback = null;
|
|
109
|
+
cb();
|
|
110
|
+
},
|
|
111
|
+
flushLowPri: function () {
|
|
112
|
+
var timeout = arguments.length <= 0 || arguments[0] === undefined ? Infinity : arguments[0];
|
|
113
|
+
|
|
114
|
+
var cb = scheduledLowPriCallback;
|
|
115
|
+
if (cb === null) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
scheduledLowPriCallback = null;
|
|
119
|
+
var timeRemaining = timeout;
|
|
120
|
+
cb({
|
|
121
|
+
timeRemaining: function () {
|
|
122
|
+
// Simulate a fix amount of time progressing between each call.
|
|
123
|
+
timeRemaining -= 5;
|
|
124
|
+
if (timeRemaining < 0) {
|
|
125
|
+
timeRemaining = 0;
|
|
126
|
+
}
|
|
127
|
+
return timeRemaining;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
flush: function () {
|
|
132
|
+
ReactNoop.flushHighPri();
|
|
133
|
+
ReactNoop.flushLowPri();
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
// Logs the current state of the tree.
|
|
138
|
+
dumpTree: function () {
|
|
139
|
+
if (!root) {
|
|
140
|
+
console.log('Nothing rendered yet.');
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function logHostInstances(children, depth) {
|
|
145
|
+
for (var i = 0; i < children.length; i++) {
|
|
146
|
+
var child = children[i];
|
|
147
|
+
console.log(' '.repeat(depth) + '- ' + child.type + '#' + child.id);
|
|
148
|
+
logHostInstances(child.children, depth + 1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function logContainer(container, depth) {
|
|
152
|
+
console.log(' '.repeat(depth) + '- [root#' + container.rootID + ']');
|
|
153
|
+
logHostInstances(container.children, depth + 1);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function logFiber(fiber, depth) {
|
|
157
|
+
console.log(' '.repeat(depth) + '- ' + (fiber.type ? fiber.type.name || fiber.type : '[root]'), '[' + fiber.pendingWorkPriority + (fiber.pendingProps ? '*' : '') + ']');
|
|
158
|
+
if (fiber.child) {
|
|
159
|
+
logFiber(fiber.child, depth + 1);
|
|
160
|
+
}
|
|
161
|
+
if (fiber.sibling) {
|
|
162
|
+
logFiber(fiber.sibling, depth);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
console.log('HOST INSTANCES:');
|
|
167
|
+
logContainer(rootContainer, 0);
|
|
168
|
+
console.log('FIBERS:');
|
|
169
|
+
logFiber(root.stateNode.current, 0);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
module.exports = ReactNoop;
|