react-test-renderer 15.5.0 → 15.5.4
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/lib/ReactShallowRenderer.js +6 -0
- package/lib/shallow/ARIADOMPropertyConfig.js +73 -0
- package/lib/shallow/AutoFocusUtils.js +23 -0
- package/lib/shallow/BeforeInputEventPlugin.js +384 -0
- package/lib/shallow/CSSProperty.js +147 -0
- package/lib/shallow/CSSPropertyOperations.js +208 -0
- package/lib/shallow/CallbackQueue.js +118 -0
- package/lib/shallow/ChangeEventPlugin.js +345 -0
- package/lib/shallow/DOMChildrenOperations.js +224 -0
- package/lib/shallow/DOMLazyTree.js +117 -0
- package/lib/shallow/DOMNamespaces.js +19 -0
- package/lib/shallow/DOMProperty.js +209 -0
- package/lib/shallow/DOMPropertyOperations.js +236 -0
- package/lib/shallow/Danger.js +47 -0
- package/lib/shallow/DefaultEventPluginOrder.js +25 -0
- package/lib/shallow/EnterLeaveEventPlugin.js +99 -0
- package/lib/shallow/EventConstants.js +91 -0
- package/lib/shallow/EventPluginHub.js +277 -0
- package/lib/shallow/EventPluginRegistry.js +254 -0
- package/lib/shallow/EventPluginUtils.js +225 -0
- package/lib/shallow/EventPropagators.js +133 -0
- package/lib/shallow/FallbackCompositionState.js +94 -0
- package/lib/shallow/HTMLDOMPropertyConfig.js +235 -0
- package/lib/shallow/KeyEscapeUtils.js +58 -0
- package/lib/shallow/LinkedValueUtils.js +137 -0
- package/lib/shallow/PluginModuleType.js +12 -0
- package/lib/shallow/PooledClass.js +111 -0
- package/lib/shallow/ReactBrowserEventEmitter.js +327 -0
- package/lib/shallow/ReactChildFiber.js +243 -0
- package/lib/shallow/ReactChildReconciler.js +153 -0
- package/lib/shallow/ReactComponentBrowserEnvironment.js +29 -0
- package/lib/shallow/ReactComponentEnvironment.js +45 -0
- package/lib/shallow/ReactCompositeComponent.js +901 -0
- package/lib/shallow/ReactCoroutine.js +80 -0
- package/lib/shallow/ReactDOM.js +110 -0
- package/lib/shallow/ReactDOMComponent.js +1000 -0
- package/lib/shallow/ReactDOMComponentFlags.js +17 -0
- package/lib/shallow/ReactDOMComponentTree.js +194 -0
- package/lib/shallow/ReactDOMContainerInfo.js +32 -0
- package/lib/shallow/ReactDOMEmptyComponent.js +59 -0
- package/lib/shallow/ReactDOMFeatureFlags.js +18 -0
- package/lib/shallow/ReactDOMFiber.js +97 -0
- package/lib/shallow/ReactDOMIDOperations.js +33 -0
- package/lib/shallow/ReactDOMInput.js +284 -0
- package/lib/shallow/ReactDOMInvalidARIAHook.js +92 -0
- package/lib/shallow/ReactDOMNullInputValuePropHook.js +42 -0
- package/lib/shallow/ReactDOMOption.js +122 -0
- package/lib/shallow/ReactDOMSelect.js +199 -0
- package/lib/shallow/ReactDOMSelection.js +211 -0
- package/lib/shallow/ReactDOMServer.js +25 -0
- package/lib/shallow/ReactDOMTextComponent.js +163 -0
- package/lib/shallow/ReactDOMTextarea.js +159 -0
- package/lib/shallow/ReactDOMTreeTraversal.js +135 -0
- package/lib/shallow/ReactDOMUnknownPropertyHook.js +111 -0
- package/lib/shallow/ReactDebugTool.js +358 -0
- package/lib/shallow/ReactDefaultBatchingStrategy.js +67 -0
- package/lib/shallow/ReactDefaultInjection.js +85 -0
- package/lib/shallow/ReactElementSymbol.js +19 -0
- package/lib/shallow/ReactEmptyComponent.js +29 -0
- package/lib/shallow/ReactErrorUtils.js +75 -0
- package/lib/shallow/ReactEventEmitterMixin.js +32 -0
- package/lib/shallow/ReactEventListener.js +154 -0
- package/lib/shallow/ReactFeatureFlags.js +21 -0
- package/lib/shallow/ReactFiber.js +190 -0
- package/lib/shallow/ReactFiberBeginWork.js +380 -0
- package/lib/shallow/ReactFiberCommitWork.js +78 -0
- package/lib/shallow/ReactFiberCompleteWork.js +208 -0
- package/lib/shallow/ReactFiberReconciler.js +64 -0
- package/lib/shallow/ReactFiberRoot.js +29 -0
- package/lib/shallow/ReactFiberScheduler.js +331 -0
- package/lib/shallow/ReactFiberUpdateQueue.js +77 -0
- package/lib/shallow/ReactHostComponent.js +67 -0
- package/lib/shallow/ReactHostOperationHistoryHook.js +33 -0
- package/lib/shallow/ReactInjection.js +33 -0
- package/lib/shallow/ReactInputSelection.js +123 -0
- package/lib/shallow/ReactInstanceMap.js +47 -0
- package/lib/shallow/ReactInstanceType.js +12 -0
- package/lib/shallow/ReactInstrumentation.js +23 -0
- package/lib/shallow/ReactInvalidSetStateWarningHook.js +36 -0
- package/lib/shallow/ReactMarkupChecksum.js +49 -0
- package/lib/shallow/ReactMount.js +537 -0
- package/lib/shallow/ReactMultiChild.js +449 -0
- package/lib/shallow/ReactMultiChildUpdateTypes.js +18 -0
- package/lib/shallow/ReactNodeTypes.js +39 -0
- package/lib/shallow/ReactOwner.js +93 -0
- package/lib/shallow/ReactPerf.js +500 -0
- package/lib/shallow/ReactPriorityLevel.js +20 -0
- package/lib/shallow/ReactPropTypeLocationNames.js +24 -0
- package/lib/shallow/ReactPropTypeLocations.js +12 -0
- package/lib/shallow/ReactPropTypesSecret.js +16 -0
- package/lib/shallow/ReactReconcileTransaction.js +177 -0
- package/lib/shallow/ReactReconciler.js +167 -0
- package/lib/shallow/ReactRef.js +88 -0
- package/lib/shallow/ReactReifiedYield.js +30 -0
- package/lib/shallow/ReactServerBatchingStrategy.js +21 -0
- package/lib/shallow/ReactServerRendering.js +89 -0
- package/lib/shallow/ReactServerRenderingTransaction.js +89 -0
- package/lib/shallow/ReactServerUpdateQueue.js +138 -0
- package/lib/shallow/ReactShallowRenderer.js +150 -0
- package/lib/shallow/ReactSimpleEmptyComponent.js +36 -0
- package/lib/shallow/ReactSyntheticEventType.js +14 -0
- package/lib/shallow/ReactTestEmptyComponent.js +36 -0
- package/lib/shallow/ReactTestMount.js +131 -0
- package/lib/shallow/ReactTestReconcileTransaction.js +128 -0
- package/lib/shallow/ReactTestRenderer.js +139 -0
- package/lib/shallow/ReactTestTextComponent.js +40 -0
- package/lib/shallow/ReactTypeOfWork.js +23 -0
- package/lib/shallow/ReactTypes.js +12 -0
- package/lib/shallow/ReactUpdateQueue.js +235 -0
- package/lib/shallow/ReactUpdates.js +250 -0
- package/lib/shallow/ReactVersion.js +13 -0
- package/lib/shallow/ResponderEventPlugin.js +507 -0
- package/lib/shallow/ResponderSyntheticEvent.js +38 -0
- package/lib/shallow/ResponderTouchHistoryStore.js +183 -0
- package/lib/shallow/SVGDOMPropertyConfig.js +301 -0
- package/lib/shallow/SelectEventPlugin.js +190 -0
- package/lib/shallow/SimpleEventPlugin.js +227 -0
- package/lib/shallow/SyntheticAnimationEvent.js +38 -0
- package/lib/shallow/SyntheticClipboardEvent.js +37 -0
- package/lib/shallow/SyntheticCompositionEvent.js +35 -0
- package/lib/shallow/SyntheticDragEvent.js +35 -0
- package/lib/shallow/SyntheticEvent.js +267 -0
- package/lib/shallow/SyntheticFocusEvent.js +35 -0
- package/lib/shallow/SyntheticInputEvent.js +36 -0
- package/lib/shallow/SyntheticKeyboardEvent.js +83 -0
- package/lib/shallow/SyntheticMouseEvent.js +71 -0
- package/lib/shallow/SyntheticTouchEvent.js +44 -0
- package/lib/shallow/SyntheticTransitionEvent.js +38 -0
- package/lib/shallow/SyntheticUIEvent.js +58 -0
- package/lib/shallow/SyntheticWheelEvent.js +53 -0
- package/lib/shallow/TapEventPlugin.js +115 -0
- package/lib/shallow/TouchHistoryMath.js +98 -0
- package/lib/shallow/Transaction.js +224 -0
- package/lib/shallow/ViewportMetrics.js +26 -0
- package/lib/shallow/accumulate.js +45 -0
- package/lib/shallow/accumulateInto.js +57 -0
- package/lib/shallow/adler32.js +43 -0
- package/lib/shallow/canDefineProperty.js +25 -0
- package/lib/shallow/checkReactTypeSpec.js +86 -0
- package/lib/shallow/createMicrosoftUnsafeLocalFunction.js +31 -0
- package/lib/shallow/dangerousStyleValue.js +78 -0
- package/lib/shallow/deprecated.js +56 -0
- package/lib/shallow/escapeTextContentForBrowser.js +122 -0
- package/lib/shallow/findDOMNode.js +59 -0
- package/lib/shallow/flattenChildren.js +75 -0
- package/lib/shallow/forEachAccumulated.js +30 -0
- package/lib/shallow/getEventCharCode.js +49 -0
- package/lib/shallow/getEventKey.js +101 -0
- package/lib/shallow/getEventModifierState.js +42 -0
- package/lib/shallow/getEventTarget.js +34 -0
- package/lib/shallow/getHostComponentFromComposite.js +29 -0
- package/lib/shallow/getIteratorFn.js +40 -0
- package/lib/shallow/getNodeForCharacterOffset.js +73 -0
- package/lib/shallow/getTextContentAccessor.js +32 -0
- package/lib/shallow/getVendorPrefixedEventName.js +100 -0
- package/lib/shallow/instantiateReactComponent.js +128 -0
- package/lib/shallow/isEventSupported.js +59 -0
- package/lib/shallow/isTextInputElement.js +50 -0
- package/lib/shallow/quoteAttributeValueForBrowser.js +25 -0
- package/lib/shallow/reactProdInvariant.js +38 -0
- package/lib/shallow/renderSubtreeIntoContainer.js +15 -0
- package/lib/shallow/setInnerHTML.js +97 -0
- package/lib/shallow/setTextContent.js +51 -0
- package/lib/shallow/shouldUpdateReactComponent.js +41 -0
- package/lib/shallow/traverseAllChildren.js +175 -0
- package/lib/shallow/validateDOMNesting.js +376 -0
- package/package.json +1 -1
- package/shallow.js +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var ReactDOMComponentFlags = {
|
|
14
|
+
hasCachedChildNodes: 1 << 0
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports = ReactDOMComponentFlags;
|
|
@@ -0,0 +1,194 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
14
|
+
|
|
15
|
+
var DOMProperty = require('./DOMProperty');
|
|
16
|
+
var ReactDOMComponentFlags = require('./ReactDOMComponentFlags');
|
|
17
|
+
|
|
18
|
+
var invariant = require('fbjs/lib/invariant');
|
|
19
|
+
|
|
20
|
+
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
|
|
21
|
+
var Flags = ReactDOMComponentFlags;
|
|
22
|
+
|
|
23
|
+
var internalInstanceKey = '__reactInternalInstance$' + Math.random().toString(36).slice(2);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Check if a given node should be cached.
|
|
27
|
+
*/
|
|
28
|
+
function shouldPrecacheNode(node, nodeID) {
|
|
29
|
+
return node.nodeType === 1 && node.getAttribute(ATTR_NAME) === String(nodeID) || node.nodeType === 8 && node.nodeValue === ' react-text: ' + nodeID + ' ' || node.nodeType === 8 && node.nodeValue === ' react-empty: ' + nodeID + ' ';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Drill down (through composites and empty components) until we get a host or
|
|
34
|
+
* host text component.
|
|
35
|
+
*
|
|
36
|
+
* This is pretty polymorphic but unavoidable with the current structure we have
|
|
37
|
+
* for `_renderedChildren`.
|
|
38
|
+
*/
|
|
39
|
+
function getRenderedHostOrTextFromComponent(component) {
|
|
40
|
+
var rendered;
|
|
41
|
+
while (rendered = component._renderedComponent) {
|
|
42
|
+
component = rendered;
|
|
43
|
+
}
|
|
44
|
+
return component;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Populate `_hostNode` on the rendered host/text component with the given
|
|
49
|
+
* DOM node. The passed `inst` can be a composite.
|
|
50
|
+
*/
|
|
51
|
+
function precacheNode(inst, node) {
|
|
52
|
+
var hostInst = getRenderedHostOrTextFromComponent(inst);
|
|
53
|
+
hostInst._hostNode = node;
|
|
54
|
+
node[internalInstanceKey] = hostInst;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function uncacheNode(inst) {
|
|
58
|
+
var node = inst._hostNode;
|
|
59
|
+
if (node) {
|
|
60
|
+
delete node[internalInstanceKey];
|
|
61
|
+
inst._hostNode = null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Populate `_hostNode` on each child of `inst`, assuming that the children
|
|
67
|
+
* match up with the DOM (element) children of `node`.
|
|
68
|
+
*
|
|
69
|
+
* We cache entire levels at once to avoid an n^2 problem where we access the
|
|
70
|
+
* children of a node sequentially and have to walk from the start to our target
|
|
71
|
+
* node every time.
|
|
72
|
+
*
|
|
73
|
+
* Since we update `_renderedChildren` and the actual DOM at (slightly)
|
|
74
|
+
* different times, we could race here and see a newer `_renderedChildren` than
|
|
75
|
+
* the DOM nodes we see. To avoid this, ReactMultiChild calls
|
|
76
|
+
* `prepareToManageChildren` before we change `_renderedChildren`, at which
|
|
77
|
+
* time the container's child nodes are always cached (until it unmounts).
|
|
78
|
+
*/
|
|
79
|
+
function precacheChildNodes(inst, node) {
|
|
80
|
+
if (inst._flags & Flags.hasCachedChildNodes) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
var children = inst._renderedChildren;
|
|
84
|
+
var childNode = node.firstChild;
|
|
85
|
+
outer: for (var name in children) {
|
|
86
|
+
if (!children.hasOwnProperty(name)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
var childInst = children[name];
|
|
90
|
+
var childID = getRenderedHostOrTextFromComponent(childInst)._domID;
|
|
91
|
+
if (childID === 0) {
|
|
92
|
+
// We're currently unmounting this child in ReactMultiChild; skip it.
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
// We assume the child nodes are in the same order as the child instances.
|
|
96
|
+
for (; childNode !== null; childNode = childNode.nextSibling) {
|
|
97
|
+
if (shouldPrecacheNode(childNode, childID)) {
|
|
98
|
+
precacheNode(childInst, childNode);
|
|
99
|
+
continue outer;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// We reached the end of the DOM children without finding an ID match.
|
|
103
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unable to find element with ID %s.', childID) : _prodInvariant('32', childID) : void 0;
|
|
104
|
+
}
|
|
105
|
+
inst._flags |= Flags.hasCachedChildNodes;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Given a DOM node, return the closest ReactDOMComponent or
|
|
110
|
+
* ReactDOMTextComponent instance ancestor.
|
|
111
|
+
*/
|
|
112
|
+
function getClosestInstanceFromNode(node) {
|
|
113
|
+
if (node[internalInstanceKey]) {
|
|
114
|
+
return node[internalInstanceKey];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Walk up the tree until we find an ancestor whose instance we have cached.
|
|
118
|
+
var parents = [];
|
|
119
|
+
while (!node[internalInstanceKey]) {
|
|
120
|
+
parents.push(node);
|
|
121
|
+
if (node.parentNode) {
|
|
122
|
+
node = node.parentNode;
|
|
123
|
+
} else {
|
|
124
|
+
// Top of the tree. This node must not be part of a React tree (or is
|
|
125
|
+
// unmounted, potentially).
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var closest;
|
|
131
|
+
var inst;
|
|
132
|
+
for (; node && (inst = node[internalInstanceKey]); node = parents.pop()) {
|
|
133
|
+
closest = inst;
|
|
134
|
+
if (parents.length) {
|
|
135
|
+
precacheChildNodes(inst, node);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return closest;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
|
|
144
|
+
* instance, or null if the node was not rendered by this React.
|
|
145
|
+
*/
|
|
146
|
+
function getInstanceFromNode(node) {
|
|
147
|
+
var inst = getClosestInstanceFromNode(node);
|
|
148
|
+
if (inst != null && inst._hostNode === node) {
|
|
149
|
+
return inst;
|
|
150
|
+
} else {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
|
|
157
|
+
* DOM node.
|
|
158
|
+
*/
|
|
159
|
+
function getNodeFromInstance(inst) {
|
|
160
|
+
// Without this first invariant, passing a non-DOM-component triggers the next
|
|
161
|
+
// invariant for a missing parent, which is super confusing.
|
|
162
|
+
!(inst._hostNode !== undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : _prodInvariant('33') : void 0;
|
|
163
|
+
|
|
164
|
+
if (inst._hostNode) {
|
|
165
|
+
return inst._hostNode;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Walk up the tree until we find an ancestor whose DOM node we have cached.
|
|
169
|
+
var parents = [];
|
|
170
|
+
while (!inst._hostNode) {
|
|
171
|
+
parents.push(inst);
|
|
172
|
+
!inst._hostParent ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React DOM tree root should always have a node reference.') : _prodInvariant('34') : void 0;
|
|
173
|
+
inst = inst._hostParent;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Now parents contains each ancestor that does *not* have a cached native
|
|
177
|
+
// node, and `inst` is the deepest ancestor that does.
|
|
178
|
+
for (; parents.length; inst = parents.pop()) {
|
|
179
|
+
precacheChildNodes(inst, inst._hostNode);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return inst._hostNode;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
var ReactDOMComponentTree = {
|
|
186
|
+
getClosestInstanceFromNode: getClosestInstanceFromNode,
|
|
187
|
+
getInstanceFromNode: getInstanceFromNode,
|
|
188
|
+
getNodeFromInstance: getNodeFromInstance,
|
|
189
|
+
precacheChildNodes: precacheChildNodes,
|
|
190
|
+
precacheNode: precacheNode,
|
|
191
|
+
uncacheNode: uncacheNode
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
module.exports = ReactDOMComponentTree;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var validateDOMNesting = require('./validateDOMNesting');
|
|
14
|
+
|
|
15
|
+
var DOC_NODE_TYPE = 9;
|
|
16
|
+
|
|
17
|
+
function ReactDOMContainerInfo(topLevelWrapper, node) {
|
|
18
|
+
var info = {
|
|
19
|
+
_topLevelWrapper: topLevelWrapper,
|
|
20
|
+
_idCounter: 1,
|
|
21
|
+
_ownerDocument: node ? node.nodeType === DOC_NODE_TYPE ? node : node.ownerDocument : null,
|
|
22
|
+
_node: node,
|
|
23
|
+
_tag: node ? node.nodeName.toLowerCase() : null,
|
|
24
|
+
_namespaceURI: node ? node.namespaceURI : null
|
|
25
|
+
};
|
|
26
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
27
|
+
info._ancestorInfo = node ? validateDOMNesting.updatedAncestorInfo(null, info._tag, null) : null;
|
|
28
|
+
}
|
|
29
|
+
return info;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = ReactDOMContainerInfo;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2014-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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var _assign = require('object-assign');
|
|
14
|
+
|
|
15
|
+
var DOMLazyTree = require('./DOMLazyTree');
|
|
16
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
17
|
+
|
|
18
|
+
var ReactDOMEmptyComponent = function (instantiate) {
|
|
19
|
+
// ReactCompositeComponent uses this:
|
|
20
|
+
this._currentElement = null;
|
|
21
|
+
// ReactDOMComponentTree uses these:
|
|
22
|
+
this._hostNode = null;
|
|
23
|
+
this._hostParent = null;
|
|
24
|
+
this._hostContainerInfo = null;
|
|
25
|
+
this._domID = 0;
|
|
26
|
+
};
|
|
27
|
+
_assign(ReactDOMEmptyComponent.prototype, {
|
|
28
|
+
mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
|
|
29
|
+
var domID = hostContainerInfo._idCounter++;
|
|
30
|
+
this._domID = domID;
|
|
31
|
+
this._hostParent = hostParent;
|
|
32
|
+
this._hostContainerInfo = hostContainerInfo;
|
|
33
|
+
|
|
34
|
+
var nodeValue = ' react-empty: ' + this._domID + ' ';
|
|
35
|
+
if (transaction.useCreateElement) {
|
|
36
|
+
var ownerDocument = hostContainerInfo._ownerDocument;
|
|
37
|
+
var node = ownerDocument.createComment(nodeValue);
|
|
38
|
+
ReactDOMComponentTree.precacheNode(this, node);
|
|
39
|
+
return DOMLazyTree(node);
|
|
40
|
+
} else {
|
|
41
|
+
if (transaction.renderToStaticMarkup) {
|
|
42
|
+
// Normally we'd insert a comment node, but since this is a situation
|
|
43
|
+
// where React won't take over (static pages), we can simply return
|
|
44
|
+
// nothing.
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
return '<!--' + nodeValue + '-->';
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
receiveComponent: function () {},
|
|
51
|
+
getHostNode: function () {
|
|
52
|
+
return ReactDOMComponentTree.getNodeFromInstance(this);
|
|
53
|
+
},
|
|
54
|
+
unmountComponent: function () {
|
|
55
|
+
ReactDOMComponentTree.uncacheNode(this);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
module.exports = ReactDOMEmptyComponent;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var ReactDOMFeatureFlags = {
|
|
14
|
+
useCreateElement: true,
|
|
15
|
+
useFiber: false
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
module.exports = ReactDOMFeatureFlags;
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactFiberReconciler = require('./ReactFiberReconciler');
|
|
15
|
+
|
|
16
|
+
var warning = require('fbjs/lib/warning');
|
|
17
|
+
|
|
18
|
+
function recursivelyAppendChildren(parent, child) {
|
|
19
|
+
if (!child) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
/* $FlowFixMe: Element should have this property. */
|
|
23
|
+
if (child.nodeType === 1) {
|
|
24
|
+
/* $FlowFixMe: Refinement issue. I don't know how to express different. */
|
|
25
|
+
parent.appendChild(child);
|
|
26
|
+
} else {
|
|
27
|
+
/* As a result of the refinement issue this type isn't known. */
|
|
28
|
+
var node = child;
|
|
29
|
+
do {
|
|
30
|
+
recursivelyAppendChildren(parent, node.output);
|
|
31
|
+
} while (node = node.sibling);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var DOMRenderer = ReactFiberReconciler({
|
|
36
|
+
updateContainer: function (container, children) {
|
|
37
|
+
container.innerHTML = '';
|
|
38
|
+
recursivelyAppendChildren(container, children);
|
|
39
|
+
},
|
|
40
|
+
createInstance: function (type, props, children) {
|
|
41
|
+
var domElement = document.createElement(type);
|
|
42
|
+
recursivelyAppendChildren(domElement, children);
|
|
43
|
+
if (typeof props.children === 'string') {
|
|
44
|
+
domElement.textContent = props.children;
|
|
45
|
+
}
|
|
46
|
+
return domElement;
|
|
47
|
+
},
|
|
48
|
+
prepareUpdate: function (domElement, oldProps, newProps, children) {
|
|
49
|
+
return true;
|
|
50
|
+
},
|
|
51
|
+
commitUpdate: function (domElement, oldProps, newProps, children) {
|
|
52
|
+
domElement.innerHTML = '';
|
|
53
|
+
recursivelyAppendChildren(domElement, children);
|
|
54
|
+
if (typeof newProps.children === 'string') {
|
|
55
|
+
domElement.textContent = newProps.children;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
deleteInstance: function (instance) {
|
|
59
|
+
// Noop
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
scheduleAnimationCallback: window.requestAnimationFrame,
|
|
64
|
+
|
|
65
|
+
scheduleDeferredCallback: window.requestIdleCallback
|
|
66
|
+
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
var warned = false;
|
|
70
|
+
|
|
71
|
+
function warnAboutUnstableUse() {
|
|
72
|
+
process.env.NODE_ENV !== 'production' ? warning(warned, 'You are using React DOM Fiber which is an experimental renderer. ' + 'It is likely to have bugs, breaking changes and is unsupported.') : void 0;
|
|
73
|
+
warned = true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var ReactDOM = {
|
|
77
|
+
render: function (element, container) {
|
|
78
|
+
warnAboutUnstableUse();
|
|
79
|
+
if (!container._reactRootContainer) {
|
|
80
|
+
container._reactRootContainer = DOMRenderer.mountContainer(element, container);
|
|
81
|
+
} else {
|
|
82
|
+
DOMRenderer.updateContainer(element, container._reactRootContainer);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
unmountComponentAtNode: function (container) {
|
|
86
|
+
warnAboutUnstableUse();
|
|
87
|
+
var root = container._reactRootContainer;
|
|
88
|
+
if (root) {
|
|
89
|
+
// TODO: Is it safe to reset this now or should I wait since this
|
|
90
|
+
// unmount could be deferred?
|
|
91
|
+
container._reactRootContainer = null;
|
|
92
|
+
DOMRenderer.unmountContainer(root);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
module.exports = ReactDOM;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var DOMChildrenOperations = require('./DOMChildrenOperations');
|
|
14
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Operations used to process updates to DOM nodes.
|
|
18
|
+
*/
|
|
19
|
+
var ReactDOMIDOperations = {
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Updates a component's children by processing a series of updates.
|
|
23
|
+
*
|
|
24
|
+
* @param {array<object>} updates List of update configurations.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
dangerouslyProcessChildrenUpdates: function (parentInst, updates) {
|
|
28
|
+
var node = ReactDOMComponentTree.getNodeFromInstance(parentInst);
|
|
29
|
+
DOMChildrenOperations.processUpdates(node, updates);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = ReactDOMIDOperations;
|