react 0.14.10 → 15.0.0
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/LICENSE +1 -1
- package/dist/react-with-addons.js +4900 -4627
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4556 -4059
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +49 -19
- package/lib/CallbackQueue.js +16 -4
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +91 -61
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +42 -53
- package/lib/Danger.js +13 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +22 -66
- package/lib/EventPluginRegistry.js +30 -9
- package/lib/EventPluginUtils.js +61 -36
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +4 -4
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +6 -7
- package/lib/MetaMatchers.js +2 -2
- package/lib/OrderedMap.js +17 -16
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +50 -20
- package/lib/ReactBrowserEventEmitter.js +19 -26
- package/lib/ReactCSSTransitionGroup.js +4 -5
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +44 -92
- package/lib/ReactComponent.js +9 -10
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +166 -74
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +186 -250
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +73 -23
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +14 -12
- package/lib/ReactDOMSelect.js +43 -19
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +87 -45
- package/lib/ReactDOMTextarea.js +39 -11
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugInstanceMap.js +102 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +4 -3
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +105 -26
- package/lib/ReactDefaultPerfAnalysis.js +23 -15
- package/lib/ReactElement.js +63 -23
- package/lib/ReactElementValidator.js +9 -9
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +23 -77
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +6 -6
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -12
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +88 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -5
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +7 -6
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +5 -4
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +20 -9
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +17 -35
- package/lib/ReactServerRenderingTransaction.js +11 -29
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +47 -28
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +4 -3
- package/lib/ReactUMDEntry.js +26 -0
- package/lib/ReactUpdateQueue.js +24 -66
- package/lib/ReactUpdates.js +29 -11
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -21
- package/lib/ReactWithAddonsUMDEntry.js +26 -0
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +57 -17
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +102 -21
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +2 -2
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +7 -4
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +2 -2
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +12 -13
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +2 -2
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +5 -4
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +6 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +8 -8
- package/lib/update.js +16 -15
- package/lib/validateDOMNesting.js +18 -13
- package/package.json +23 -32
- package/addons.js +0 -13
- package/cjs/react-jsx-dev-runtime.development.js +0 -861
- package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
- package/cjs/react-jsx-runtime.development.js +0 -883
- package/cjs/react-jsx-runtime.production.min.js +0 -10
- package/jsx-dev-runtime.js +0 -7
- package/jsx-runtime.js +0 -7
- package/lib/Object.assign.js +0 -47
- package/lib/React.native.js +0 -5
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactIsomorphic.js +0 -74
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
* @providesModule ReactDOMComponentFlags
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactDOMComponentFlags = {
|
|
15
|
+
hasCachedChildNodes: 1 << 0
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
module.exports = ReactDOMComponentFlags;
|
|
@@ -0,0 +1,186 @@
|
|
|
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 ReactDOMComponentTree
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var DOMProperty = require('./DOMProperty');
|
|
15
|
+
var ReactDOMComponentFlags = require('./ReactDOMComponentFlags');
|
|
16
|
+
|
|
17
|
+
var invariant = require('fbjs/lib/invariant');
|
|
18
|
+
|
|
19
|
+
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
|
|
20
|
+
var Flags = ReactDOMComponentFlags;
|
|
21
|
+
|
|
22
|
+
var internalInstanceKey = '__reactInternalInstance$' + Math.random().toString(36).slice(2);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Drill down (through composites and empty components) until we get a native or
|
|
26
|
+
* native text component.
|
|
27
|
+
*
|
|
28
|
+
* This is pretty polymorphic but unavoidable with the current structure we have
|
|
29
|
+
* for `_renderedChildren`.
|
|
30
|
+
*/
|
|
31
|
+
function getRenderedNativeOrTextFromComponent(component) {
|
|
32
|
+
var rendered;
|
|
33
|
+
while (rendered = component._renderedComponent) {
|
|
34
|
+
component = rendered;
|
|
35
|
+
}
|
|
36
|
+
return component;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Populate `_nativeNode` on the rendered native/text component with the given
|
|
41
|
+
* DOM node. The passed `inst` can be a composite.
|
|
42
|
+
*/
|
|
43
|
+
function precacheNode(inst, node) {
|
|
44
|
+
var nativeInst = getRenderedNativeOrTextFromComponent(inst);
|
|
45
|
+
nativeInst._nativeNode = node;
|
|
46
|
+
node[internalInstanceKey] = nativeInst;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function uncacheNode(inst) {
|
|
50
|
+
var node = inst._nativeNode;
|
|
51
|
+
if (node) {
|
|
52
|
+
delete node[internalInstanceKey];
|
|
53
|
+
inst._nativeNode = null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Populate `_nativeNode` on each child of `inst`, assuming that the children
|
|
59
|
+
* match up with the DOM (element) children of `node`.
|
|
60
|
+
*
|
|
61
|
+
* We cache entire levels at once to avoid an n^2 problem where we access the
|
|
62
|
+
* children of a node sequentially and have to walk from the start to our target
|
|
63
|
+
* node every time.
|
|
64
|
+
*
|
|
65
|
+
* Since we update `_renderedChildren` and the actual DOM at (slightly)
|
|
66
|
+
* different times, we could race here and see a newer `_renderedChildren` than
|
|
67
|
+
* the DOM nodes we see. To avoid this, ReactMultiChild calls
|
|
68
|
+
* `prepareToManageChildren` before we change `_renderedChildren`, at which
|
|
69
|
+
* time the container's child nodes are always cached (until it unmounts).
|
|
70
|
+
*/
|
|
71
|
+
function precacheChildNodes(inst, node) {
|
|
72
|
+
if (inst._flags & Flags.hasCachedChildNodes) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
var children = inst._renderedChildren;
|
|
76
|
+
var childNode = node.firstChild;
|
|
77
|
+
outer: for (var name in children) {
|
|
78
|
+
if (!children.hasOwnProperty(name)) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
var childInst = children[name];
|
|
82
|
+
var childID = getRenderedNativeOrTextFromComponent(childInst)._domID;
|
|
83
|
+
if (childID == null) {
|
|
84
|
+
// We're currently unmounting this child in ReactMultiChild; skip it.
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// We assume the child nodes are in the same order as the child instances.
|
|
88
|
+
for (; childNode !== null; childNode = childNode.nextSibling) {
|
|
89
|
+
if (childNode.nodeType === 1 && childNode.getAttribute(ATTR_NAME) === String(childID) || childNode.nodeType === 8 && childNode.nodeValue === ' react-text: ' + childID + ' ' || childNode.nodeType === 8 && childNode.nodeValue === ' react-empty: ' + childID + ' ') {
|
|
90
|
+
precacheNode(childInst, childNode);
|
|
91
|
+
continue outer;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// We reached the end of the DOM children without finding an ID match.
|
|
95
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unable to find element with ID %s.', childID) : invariant(false) : void 0;
|
|
96
|
+
}
|
|
97
|
+
inst._flags |= Flags.hasCachedChildNodes;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Given a DOM node, return the closest ReactDOMComponent or
|
|
102
|
+
* ReactDOMTextComponent instance ancestor.
|
|
103
|
+
*/
|
|
104
|
+
function getClosestInstanceFromNode(node) {
|
|
105
|
+
if (node[internalInstanceKey]) {
|
|
106
|
+
return node[internalInstanceKey];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Walk up the tree until we find an ancestor whose instance we have cached.
|
|
110
|
+
var parents = [];
|
|
111
|
+
while (!node[internalInstanceKey]) {
|
|
112
|
+
parents.push(node);
|
|
113
|
+
if (node.parentNode) {
|
|
114
|
+
node = node.parentNode;
|
|
115
|
+
} else {
|
|
116
|
+
// Top of the tree. This node must not be part of a React tree (or is
|
|
117
|
+
// unmounted, potentially).
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
var closest;
|
|
123
|
+
var inst;
|
|
124
|
+
for (; node && (inst = node[internalInstanceKey]); node = parents.pop()) {
|
|
125
|
+
closest = inst;
|
|
126
|
+
if (parents.length) {
|
|
127
|
+
precacheChildNodes(inst, node);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return closest;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
|
|
136
|
+
* instance, or null if the node was not rendered by this React.
|
|
137
|
+
*/
|
|
138
|
+
function getInstanceFromNode(node) {
|
|
139
|
+
var inst = getClosestInstanceFromNode(node);
|
|
140
|
+
if (inst != null && inst._nativeNode === node) {
|
|
141
|
+
return inst;
|
|
142
|
+
} else {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
|
|
149
|
+
* DOM node.
|
|
150
|
+
*/
|
|
151
|
+
function getNodeFromInstance(inst) {
|
|
152
|
+
// Without this first invariant, passing a non-DOM-component triggers the next
|
|
153
|
+
// invariant for a missing parent, which is super confusing.
|
|
154
|
+
!(inst._nativeNode !== undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : void 0;
|
|
155
|
+
|
|
156
|
+
if (inst._nativeNode) {
|
|
157
|
+
return inst._nativeNode;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Walk up the tree until we find an ancestor whose DOM node we have cached.
|
|
161
|
+
var parents = [];
|
|
162
|
+
while (!inst._nativeNode) {
|
|
163
|
+
parents.push(inst);
|
|
164
|
+
!inst._nativeParent ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React DOM tree root should always have a node reference.') : invariant(false) : void 0;
|
|
165
|
+
inst = inst._nativeParent;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Now parents contains each ancestor that does *not* have a cached native
|
|
169
|
+
// node, and `inst` is the deepest ancestor that does.
|
|
170
|
+
for (; parents.length; inst = parents.pop()) {
|
|
171
|
+
precacheChildNodes(inst, inst._nativeNode);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return inst._nativeNode;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
var ReactDOMComponentTree = {
|
|
178
|
+
getClosestInstanceFromNode: getClosestInstanceFromNode,
|
|
179
|
+
getInstanceFromNode: getInstanceFromNode,
|
|
180
|
+
getNodeFromInstance: getNodeFromInstance,
|
|
181
|
+
precacheChildNodes: precacheChildNodes,
|
|
182
|
+
precacheNode: precacheNode,
|
|
183
|
+
uncacheNode: uncacheNode
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
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
|
+
* @providesModule ReactDOMContainerInfo
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var validateDOMNesting = require('./validateDOMNesting');
|
|
15
|
+
|
|
16
|
+
var DOC_NODE_TYPE = 9;
|
|
17
|
+
|
|
18
|
+
function ReactDOMContainerInfo(topLevelWrapper, node) {
|
|
19
|
+
var info = {
|
|
20
|
+
_topLevelWrapper: topLevelWrapper,
|
|
21
|
+
_idCounter: 1,
|
|
22
|
+
_ownerDocument: node ? node.nodeType === DOC_NODE_TYPE ? node : node.ownerDocument : null,
|
|
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,61 @@
|
|
|
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 ReactDOMDebugTool
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactDOMUnknownPropertyDevtool = require('./ReactDOMUnknownPropertyDevtool');
|
|
15
|
+
|
|
16
|
+
var warning = require('fbjs/lib/warning');
|
|
17
|
+
|
|
18
|
+
var eventHandlers = [];
|
|
19
|
+
var handlerDoesThrowForEvent = {};
|
|
20
|
+
|
|
21
|
+
function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
|
|
22
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
23
|
+
eventHandlers.forEach(function (handler) {
|
|
24
|
+
try {
|
|
25
|
+
if (handler[handlerFunctionName]) {
|
|
26
|
+
handler[handlerFunctionName](arg1, arg2, arg3, arg4, arg5);
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
process.env.NODE_ENV !== 'production' ? warning(!handlerDoesThrowForEvent[handlerFunctionName], 'exception thrown by devtool while handling %s: %s', handlerFunctionName, e.message) : void 0;
|
|
30
|
+
handlerDoesThrowForEvent[handlerFunctionName] = true;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var ReactDOMDebugTool = {
|
|
37
|
+
addDevtool: function (devtool) {
|
|
38
|
+
eventHandlers.push(devtool);
|
|
39
|
+
},
|
|
40
|
+
removeDevtool: function (devtool) {
|
|
41
|
+
for (var i = 0; i < eventHandlers.length; i++) {
|
|
42
|
+
if (eventHandlers[i] === devtool) {
|
|
43
|
+
eventHandlers.splice(i, 1);
|
|
44
|
+
i--;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
onCreateMarkupForProperty: function (name, value) {
|
|
49
|
+
emitEvent('onCreateMarkupForProperty', name, value);
|
|
50
|
+
},
|
|
51
|
+
onSetValueForProperty: function (node, name, value) {
|
|
52
|
+
emitEvent('onSetValueForProperty', node, name, value);
|
|
53
|
+
},
|
|
54
|
+
onDeleteValueForProperty: function (node, name) {
|
|
55
|
+
emitEvent('onDeleteValueForProperty', node, name);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyDevtool);
|
|
60
|
+
|
|
61
|
+
module.exports = ReactDOMDebugTool;
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
* @providesModule ReactDOMEmptyComponent
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
16
|
+
var DOMLazyTree = require('./DOMLazyTree');
|
|
17
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
18
|
+
|
|
19
|
+
var ReactDOMEmptyComponent = function (instantiate) {
|
|
20
|
+
// ReactCompositeComponent uses this:
|
|
21
|
+
this._currentElement = null;
|
|
22
|
+
// ReactDOMComponentTree uses these:
|
|
23
|
+
this._nativeNode = null;
|
|
24
|
+
this._nativeParent = null;
|
|
25
|
+
this._nativeContainerInfo = null;
|
|
26
|
+
this._domID = null;
|
|
27
|
+
};
|
|
28
|
+
_assign(ReactDOMEmptyComponent.prototype, {
|
|
29
|
+
mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
|
|
30
|
+
var domID = nativeContainerInfo._idCounter++;
|
|
31
|
+
this._domID = domID;
|
|
32
|
+
this._nativeParent = nativeParent;
|
|
33
|
+
this._nativeContainerInfo = nativeContainerInfo;
|
|
34
|
+
|
|
35
|
+
var nodeValue = ' react-empty: ' + this._domID + ' ';
|
|
36
|
+
if (transaction.useCreateElement) {
|
|
37
|
+
var ownerDocument = nativeContainerInfo._ownerDocument;
|
|
38
|
+
var node = ownerDocument.createComment(nodeValue);
|
|
39
|
+
ReactDOMComponentTree.precacheNode(this, node);
|
|
40
|
+
return DOMLazyTree(node);
|
|
41
|
+
} else {
|
|
42
|
+
if (transaction.renderToStaticMarkup) {
|
|
43
|
+
// Normally we'd insert a comment node, but since this is a situation
|
|
44
|
+
// where React won't take over (static pages), we can simply return
|
|
45
|
+
// nothing.
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
return '<!--' + nodeValue + '-->';
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
receiveComponent: function () {},
|
|
52
|
+
getNativeNode: function () {
|
|
53
|
+
return ReactDOMComponentTree.getNodeFromInstance(this);
|
|
54
|
+
},
|
|
55
|
+
unmountComponent: function () {
|
|
56
|
+
ReactDOMComponentTree.uncacheNode(this);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
module.exports = ReactDOMEmptyComponent;
|
package/lib/ReactDOMFactories.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactDOMFactories
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactDOMFeatureFlags = {
|
|
15
|
-
useCreateElement:
|
|
15
|
+
useCreateElement: true
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
module.exports = ReactDOMFeatureFlags;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,87 +7,32 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactDOMIDOperations
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
15
14
|
var DOMChildrenOperations = require('./DOMChildrenOperations');
|
|
16
|
-
var
|
|
17
|
-
var ReactMount = require('./ReactMount');
|
|
15
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
18
16
|
var ReactPerf = require('./ReactPerf');
|
|
19
17
|
|
|
20
|
-
var invariant = require('fbjs/lib/invariant');
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Errors for properties that should not be updated with `updatePropertyByID()`.
|
|
24
|
-
*
|
|
25
|
-
* @type {object}
|
|
26
|
-
* @private
|
|
27
|
-
*/
|
|
28
|
-
var INVALID_PROPERTY_ERRORS = {
|
|
29
|
-
dangerouslySetInnerHTML: '`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.',
|
|
30
|
-
style: '`style` must be set using `updateStylesByID()`.'
|
|
31
|
-
};
|
|
32
|
-
|
|
33
18
|
/**
|
|
34
19
|
* Operations used to process updates to DOM nodes.
|
|
35
20
|
*/
|
|
36
21
|
var ReactDOMIDOperations = {
|
|
37
22
|
|
|
38
|
-
/**
|
|
39
|
-
* Updates a DOM node with new property values. This should only be used to
|
|
40
|
-
* update DOM properties in `DOMProperty`.
|
|
41
|
-
*
|
|
42
|
-
* @param {string} id ID of the node to update.
|
|
43
|
-
* @param {string} name A valid property name, see `DOMProperty`.
|
|
44
|
-
* @param {*} value New value of the property.
|
|
45
|
-
* @internal
|
|
46
|
-
*/
|
|
47
|
-
updatePropertyByID: function (id, name, value) {
|
|
48
|
-
var node = ReactMount.getNode(id);
|
|
49
|
-
!!INVALID_PROPERTY_ERRORS.hasOwnProperty(name) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updatePropertyByID(...): %s', INVALID_PROPERTY_ERRORS[name]) : invariant(false) : undefined;
|
|
50
|
-
|
|
51
|
-
// If we're updating to null or undefined, we should remove the property
|
|
52
|
-
// from the DOM node instead of inadvertantly setting to a string. This
|
|
53
|
-
// brings us in line with the same behavior we have on initial render.
|
|
54
|
-
if (value != null) {
|
|
55
|
-
DOMPropertyOperations.setValueForProperty(node, name, value);
|
|
56
|
-
} else {
|
|
57
|
-
DOMPropertyOperations.deleteValueForProperty(node, name);
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Replaces a DOM node that exists in the document with markup.
|
|
63
|
-
*
|
|
64
|
-
* @param {string} id ID of child to be replaced.
|
|
65
|
-
* @param {string} markup Dangerous markup to inject in place of child.
|
|
66
|
-
* @internal
|
|
67
|
-
* @see {Danger.dangerouslyReplaceNodeWithMarkup}
|
|
68
|
-
*/
|
|
69
|
-
dangerouslyReplaceNodeWithMarkupByID: function (id, markup) {
|
|
70
|
-
var node = ReactMount.getNode(id);
|
|
71
|
-
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
23
|
/**
|
|
75
24
|
* Updates a component's children by processing a series of updates.
|
|
76
25
|
*
|
|
77
26
|
* @param {array<object>} updates List of update configurations.
|
|
78
|
-
* @param {array<string>} markup List of markup strings.
|
|
79
27
|
* @internal
|
|
80
28
|
*/
|
|
81
|
-
dangerouslyProcessChildrenUpdates: function (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
DOMChildrenOperations.processUpdates(updates, markup);
|
|
29
|
+
dangerouslyProcessChildrenUpdates: function (parentInst, updates) {
|
|
30
|
+
var node = ReactDOMComponentTree.getNodeFromInstance(parentInst);
|
|
31
|
+
DOMChildrenOperations.processUpdates(node, updates);
|
|
86
32
|
}
|
|
87
33
|
};
|
|
88
34
|
|
|
89
35
|
ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
|
|
90
|
-
dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
|
|
91
36
|
dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
|
|
92
37
|
});
|
|
93
38
|
|