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
|
@@ -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,18 +7,27 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule DOMChildrenOperations
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
14
|
+
var DOMLazyTree = require('./DOMLazyTree');
|
|
15
15
|
var Danger = require('./Danger');
|
|
16
16
|
var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
|
|
17
17
|
var ReactPerf = require('./ReactPerf');
|
|
18
18
|
|
|
19
|
+
var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction');
|
|
19
20
|
var setInnerHTML = require('./setInnerHTML');
|
|
20
21
|
var setTextContent = require('./setTextContent');
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
function getNodeAfter(parentNode, node) {
|
|
24
|
+
// Special case for text components, which return [open, close] comments
|
|
25
|
+
// from getNativeNode.
|
|
26
|
+
if (Array.isArray(node)) {
|
|
27
|
+
node = node[1];
|
|
28
|
+
}
|
|
29
|
+
return node ? node.nextSibling : parentNode.firstChild;
|
|
30
|
+
}
|
|
22
31
|
|
|
23
32
|
/**
|
|
24
33
|
* Inserts `childNode` as a child of `parentNode` at the `index`.
|
|
@@ -28,17 +37,78 @@ var invariant = require('fbjs/lib/invariant');
|
|
|
28
37
|
* @param {number} index Index at which to insert the child.
|
|
29
38
|
* @internal
|
|
30
39
|
*/
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
|
|
40
|
+
var insertChildAt = createMicrosoftUnsafeLocalFunction(function (parentNode, childNode, referenceNode) {
|
|
41
|
+
// We rely exclusively on `insertBefore(node, null)` instead of also using
|
|
42
|
+
// `appendChild(node)`. (Using `undefined` is not allowed by all browsers so
|
|
43
|
+
// we are careful to use `null`.)
|
|
44
|
+
parentNode.insertBefore(childNode, referenceNode);
|
|
45
|
+
});
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
function insertLazyTreeChildAt(parentNode, childTree, referenceNode) {
|
|
48
|
+
DOMLazyTree.insertTreeBefore(parentNode, childTree, referenceNode);
|
|
49
|
+
}
|
|
40
50
|
|
|
41
|
-
|
|
51
|
+
function moveChild(parentNode, childNode, referenceNode) {
|
|
52
|
+
if (Array.isArray(childNode)) {
|
|
53
|
+
moveDelimitedText(parentNode, childNode[0], childNode[1], referenceNode);
|
|
54
|
+
} else {
|
|
55
|
+
insertChildAt(parentNode, childNode, referenceNode);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function removeChild(parentNode, childNode) {
|
|
60
|
+
if (Array.isArray(childNode)) {
|
|
61
|
+
var closingComment = childNode[1];
|
|
62
|
+
childNode = childNode[0];
|
|
63
|
+
removeDelimitedText(parentNode, childNode, closingComment);
|
|
64
|
+
parentNode.removeChild(closingComment);
|
|
65
|
+
}
|
|
66
|
+
parentNode.removeChild(childNode);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function moveDelimitedText(parentNode, openingComment, closingComment, referenceNode) {
|
|
70
|
+
var node = openingComment;
|
|
71
|
+
while (true) {
|
|
72
|
+
var nextNode = node.nextSibling;
|
|
73
|
+
insertChildAt(parentNode, node, referenceNode);
|
|
74
|
+
if (node === closingComment) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
node = nextNode;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function removeDelimitedText(parentNode, startNode, closingComment) {
|
|
82
|
+
while (true) {
|
|
83
|
+
var node = startNode.nextSibling;
|
|
84
|
+
if (node === closingComment) {
|
|
85
|
+
// The closing comment is removed by ReactMultiChild.
|
|
86
|
+
break;
|
|
87
|
+
} else {
|
|
88
|
+
parentNode.removeChild(node);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function replaceDelimitedText(openingComment, closingComment, stringText) {
|
|
94
|
+
var parentNode = openingComment.parentNode;
|
|
95
|
+
var nodeAfterComment = openingComment.nextSibling;
|
|
96
|
+
if (nodeAfterComment === closingComment) {
|
|
97
|
+
// There are no text nodes between the opening and closing comments; insert
|
|
98
|
+
// a new one if stringText isn't empty.
|
|
99
|
+
if (stringText) {
|
|
100
|
+
insertChildAt(parentNode, document.createTextNode(stringText), nodeAfterComment);
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
if (stringText) {
|
|
104
|
+
// Set the text content of the first node after the opening comment, and
|
|
105
|
+
// remove all following nodes up until the closing comment.
|
|
106
|
+
setTextContent(nodeAfterComment, stringText);
|
|
107
|
+
removeDelimitedText(parentNode, nodeAfterComment, closingComment);
|
|
108
|
+
} else {
|
|
109
|
+
removeDelimitedText(parentNode, openingComment, closingComment);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
42
112
|
}
|
|
43
113
|
|
|
44
114
|
/**
|
|
@@ -48,73 +118,33 @@ var DOMChildrenOperations = {
|
|
|
48
118
|
|
|
49
119
|
dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
|
|
50
120
|
|
|
51
|
-
|
|
121
|
+
replaceDelimitedText: replaceDelimitedText,
|
|
52
122
|
|
|
53
123
|
/**
|
|
54
124
|
* Updates a component's children by processing a series of updates. The
|
|
55
125
|
* update configurations are each expected to have a `parentNode` property.
|
|
56
126
|
*
|
|
57
127
|
* @param {array<object>} updates List of update configurations.
|
|
58
|
-
* @param {array<string>} markupList List of markup strings.
|
|
59
128
|
* @internal
|
|
60
129
|
*/
|
|
61
|
-
processUpdates: function (
|
|
62
|
-
var update;
|
|
63
|
-
// Mapping from parent IDs to initial child orderings.
|
|
64
|
-
var initialChildren = null;
|
|
65
|
-
// List of children that will be moved or removed.
|
|
66
|
-
var updatedChildren = null;
|
|
67
|
-
|
|
68
|
-
for (var i = 0; i < updates.length; i++) {
|
|
69
|
-
update = updates[i];
|
|
70
|
-
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING || update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
|
|
71
|
-
var updatedIndex = update.fromIndex;
|
|
72
|
-
var updatedChild = update.parentNode.childNodes[updatedIndex];
|
|
73
|
-
var parentID = update.parentID;
|
|
74
|
-
|
|
75
|
-
!updatedChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processUpdates(): Unable to find child %s of element. This ' + 'probably means the DOM was unexpectedly mutated (e.g., by the ' + 'browser), usually due to forgetting a <tbody> when using tables, ' + 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' + 'in an <svg> parent. Try inspecting the child nodes of the element ' + 'with React ID `%s`.', updatedIndex, parentID) : invariant(false) : undefined;
|
|
76
|
-
|
|
77
|
-
initialChildren = initialChildren || {};
|
|
78
|
-
initialChildren[parentID] = initialChildren[parentID] || [];
|
|
79
|
-
initialChildren[parentID][updatedIndex] = updatedChild;
|
|
80
|
-
|
|
81
|
-
updatedChildren = updatedChildren || [];
|
|
82
|
-
updatedChildren.push(updatedChild);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
var renderedMarkup;
|
|
87
|
-
// markupList is either a list of markup or just a list of elements
|
|
88
|
-
if (markupList.length && typeof markupList[0] === 'string') {
|
|
89
|
-
renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
|
|
90
|
-
} else {
|
|
91
|
-
renderedMarkup = markupList;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Remove updated children first so that `toIndex` is consistent.
|
|
95
|
-
if (updatedChildren) {
|
|
96
|
-
for (var j = 0; j < updatedChildren.length; j++) {
|
|
97
|
-
updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
130
|
+
processUpdates: function (parentNode, updates) {
|
|
101
131
|
for (var k = 0; k < updates.length; k++) {
|
|
102
|
-
update = updates[k];
|
|
132
|
+
var update = updates[k];
|
|
103
133
|
switch (update.type) {
|
|
104
134
|
case ReactMultiChildUpdateTypes.INSERT_MARKUP:
|
|
105
|
-
|
|
135
|
+
insertLazyTreeChildAt(parentNode, update.content, getNodeAfter(parentNode, update.afterNode));
|
|
106
136
|
break;
|
|
107
137
|
case ReactMultiChildUpdateTypes.MOVE_EXISTING:
|
|
108
|
-
|
|
138
|
+
moveChild(parentNode, update.fromNode, getNodeAfter(parentNode, update.afterNode));
|
|
109
139
|
break;
|
|
110
140
|
case ReactMultiChildUpdateTypes.SET_MARKUP:
|
|
111
|
-
setInnerHTML(
|
|
141
|
+
setInnerHTML(parentNode, update.content);
|
|
112
142
|
break;
|
|
113
143
|
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
|
|
114
|
-
setTextContent(
|
|
144
|
+
setTextContent(parentNode, update.content);
|
|
115
145
|
break;
|
|
116
146
|
case ReactMultiChildUpdateTypes.REMOVE_NODE:
|
|
117
|
-
|
|
147
|
+
removeChild(parentNode, update.fromNode);
|
|
118
148
|
break;
|
|
119
149
|
}
|
|
120
150
|
}
|
|
@@ -123,7 +153,7 @@ var DOMChildrenOperations = {
|
|
|
123
153
|
};
|
|
124
154
|
|
|
125
155
|
ReactPerf.measureMethods(DOMChildrenOperations, 'DOMChildrenOperations', {
|
|
126
|
-
|
|
156
|
+
replaceDelimitedText: 'replaceDelimitedText'
|
|
127
157
|
});
|
|
128
158
|
|
|
129
159
|
module.exports = DOMChildrenOperations;
|
|
@@ -0,0 +1,105 @@
|
|
|
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 DOMLazyTree
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction');
|
|
15
|
+
var setTextContent = require('./setTextContent');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* In IE (8-11) and Edge, appending nodes with no children is dramatically
|
|
19
|
+
* faster than appending a full subtree, so we essentially queue up the
|
|
20
|
+
* .appendChild calls here and apply them so each node is added to its parent
|
|
21
|
+
* before any children are added.
|
|
22
|
+
*
|
|
23
|
+
* In other browsers, doing so is slower or neutral compared to the other order
|
|
24
|
+
* (in Firefox, twice as slow) so we only do this inversion in IE.
|
|
25
|
+
*
|
|
26
|
+
* See https://github.com/spicyj/innerhtml-vs-createelement-vs-clonenode.
|
|
27
|
+
*/
|
|
28
|
+
var enableLazy = typeof document !== 'undefined' && typeof document.documentMode === 'number' || typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string' && /\bEdge\/\d/.test(navigator.userAgent);
|
|
29
|
+
|
|
30
|
+
function insertTreeChildren(tree) {
|
|
31
|
+
if (!enableLazy) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var node = tree.node;
|
|
35
|
+
var children = tree.children;
|
|
36
|
+
if (children.length) {
|
|
37
|
+
for (var i = 0; i < children.length; i++) {
|
|
38
|
+
insertTreeBefore(node, children[i], null);
|
|
39
|
+
}
|
|
40
|
+
} else if (tree.html != null) {
|
|
41
|
+
node.innerHTML = tree.html;
|
|
42
|
+
} else if (tree.text != null) {
|
|
43
|
+
setTextContent(node, tree.text);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var insertTreeBefore = createMicrosoftUnsafeLocalFunction(function (parentNode, tree, referenceNode) {
|
|
48
|
+
// DocumentFragments aren't actually part of the DOM after insertion so
|
|
49
|
+
// appending children won't update the DOM. We need to ensure the fragment
|
|
50
|
+
// is properly populated first, breaking out of our lazy approach for just
|
|
51
|
+
// this level.
|
|
52
|
+
if (tree.node.nodeType === 11) {
|
|
53
|
+
insertTreeChildren(tree);
|
|
54
|
+
parentNode.insertBefore(tree.node, referenceNode);
|
|
55
|
+
} else {
|
|
56
|
+
parentNode.insertBefore(tree.node, referenceNode);
|
|
57
|
+
insertTreeChildren(tree);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
function replaceChildWithTree(oldNode, newTree) {
|
|
62
|
+
oldNode.parentNode.replaceChild(newTree.node, oldNode);
|
|
63
|
+
insertTreeChildren(newTree);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function queueChild(parentTree, childTree) {
|
|
67
|
+
if (enableLazy) {
|
|
68
|
+
parentTree.children.push(childTree);
|
|
69
|
+
} else {
|
|
70
|
+
parentTree.node.appendChild(childTree.node);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function queueHTML(tree, html) {
|
|
75
|
+
if (enableLazy) {
|
|
76
|
+
tree.html = html;
|
|
77
|
+
} else {
|
|
78
|
+
tree.node.innerHTML = html;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function queueText(tree, text) {
|
|
83
|
+
if (enableLazy) {
|
|
84
|
+
tree.text = text;
|
|
85
|
+
} else {
|
|
86
|
+
setTextContent(tree.node, text);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function DOMLazyTree(node) {
|
|
91
|
+
return {
|
|
92
|
+
node: node,
|
|
93
|
+
children: [],
|
|
94
|
+
html: null,
|
|
95
|
+
text: null
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
DOMLazyTree.insertTreeBefore = insertTreeBefore;
|
|
100
|
+
DOMLazyTree.replaceChildWithTree = replaceChildWithTree;
|
|
101
|
+
DOMLazyTree.queueChild = queueChild;
|
|
102
|
+
DOMLazyTree.queueHTML = queueHTML;
|
|
103
|
+
DOMLazyTree.queueText = queueText;
|
|
104
|
+
|
|
105
|
+
module.exports = DOMLazyTree;
|
|
@@ -1,23 +1,20 @@
|
|
|
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
|
|
6
6
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
|
-
* @providesModule
|
|
10
|
-
* @typechecks
|
|
9
|
+
* @providesModule DOMNamespaces
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return nextReactRootIndex++;
|
|
20
|
-
}
|
|
14
|
+
var DOMNamespaces = {
|
|
15
|
+
html: 'http://www.w3.org/1999/xhtml',
|
|
16
|
+
mathml: 'http://www.w3.org/1998/Math/MathML',
|
|
17
|
+
svg: 'http://www.w3.org/2000/svg'
|
|
21
18
|
};
|
|
22
19
|
|
|
23
|
-
module.exports =
|
|
20
|
+
module.exports = DOMNamespaces;
|
package/lib/DOMProperty.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 DOMProperty
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -23,13 +22,12 @@ var DOMPropertyInjection = {
|
|
|
23
22
|
* Mapping from normalized, camelcased property names to a configuration that
|
|
24
23
|
* specifies how the associated DOM property should be accessed or rendered.
|
|
25
24
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
|
|
25
|
+
MUST_USE_PROPERTY: 0x1,
|
|
26
|
+
HAS_SIDE_EFFECTS: 0x2,
|
|
27
|
+
HAS_BOOLEAN_VALUE: 0x4,
|
|
28
|
+
HAS_NUMERIC_VALUE: 0x8,
|
|
29
|
+
HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8,
|
|
30
|
+
HAS_OVERLOADED_BOOLEAN_VALUE: 0x20,
|
|
33
31
|
|
|
34
32
|
/**
|
|
35
33
|
* Inject some specialized knowledge about the DOM. This takes a config object
|
|
@@ -72,7 +70,7 @@ var DOMPropertyInjection = {
|
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
for (var propName in Properties) {
|
|
75
|
-
!!DOMProperty.properties.hasOwnProperty(propName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' + '\'%s\' which has already been injected. You may be accidentally ' + 'injecting the same DOM property config twice, or you may be ' + 'injecting two configs that have conflicting property names.', propName) : invariant(false) :
|
|
73
|
+
!!DOMProperty.properties.hasOwnProperty(propName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' + '\'%s\' which has already been injected. You may be accidentally ' + 'injecting the same DOM property config twice, or you may be ' + 'injecting two configs that have conflicting property names.', propName) : invariant(false) : void 0;
|
|
76
74
|
|
|
77
75
|
var lowerCased = propName.toLowerCase();
|
|
78
76
|
var propConfig = Properties[propName];
|
|
@@ -83,7 +81,6 @@ var DOMPropertyInjection = {
|
|
|
83
81
|
propertyName: propName,
|
|
84
82
|
mutationMethod: null,
|
|
85
83
|
|
|
86
|
-
mustUseAttribute: checkMask(propConfig, Injection.MUST_USE_ATTRIBUTE),
|
|
87
84
|
mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
|
|
88
85
|
hasSideEffects: checkMask(propConfig, Injection.HAS_SIDE_EFFECTS),
|
|
89
86
|
hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
|
|
@@ -92,9 +89,8 @@ var DOMPropertyInjection = {
|
|
|
92
89
|
hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE)
|
|
93
90
|
};
|
|
94
91
|
|
|
95
|
-
!(
|
|
96
|
-
!(propertyInfo.
|
|
97
|
-
!(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName) : invariant(false) : undefined;
|
|
92
|
+
!(propertyInfo.mustUseProperty || !propertyInfo.hasSideEffects) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Properties that have side effects must use property: %s', propName) : invariant(false) : void 0;
|
|
93
|
+
!(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName) : invariant(false) : void 0;
|
|
98
94
|
|
|
99
95
|
if (process.env.NODE_ENV !== 'production') {
|
|
100
96
|
DOMProperty.getPossibleStandardName[lowerCased] = propName;
|
|
@@ -124,7 +120,10 @@ var DOMPropertyInjection = {
|
|
|
124
120
|
}
|
|
125
121
|
}
|
|
126
122
|
};
|
|
127
|
-
|
|
123
|
+
|
|
124
|
+
/* eslint-disable max-len */
|
|
125
|
+
var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
|
|
126
|
+
/* eslint-enable max-len */
|
|
128
127
|
|
|
129
128
|
/**
|
|
130
129
|
* DOMProperty exports lookup objects that can be used like functions:
|
|
@@ -142,6 +141,10 @@ var defaultValueCache = {};
|
|
|
142
141
|
var DOMProperty = {
|
|
143
142
|
|
|
144
143
|
ID_ATTRIBUTE_NAME: 'data-reactid',
|
|
144
|
+
ROOT_ATTRIBUTE_NAME: 'data-reactroot',
|
|
145
|
+
|
|
146
|
+
ATTRIBUTE_NAME_START_CHAR: ATTRIBUTE_NAME_START_CHAR,
|
|
147
|
+
ATTRIBUTE_NAME_CHAR: ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\uB7\\u0300-\\u036F\\u203F-\\u2040',
|
|
145
148
|
|
|
146
149
|
/**
|
|
147
150
|
* Map from property "standard name" to an object with info about how to set
|
|
@@ -156,9 +159,6 @@ var DOMProperty = {
|
|
|
156
159
|
* mutationMethod:
|
|
157
160
|
* If non-null, used instead of the property or `setAttribute()` after
|
|
158
161
|
* initial render.
|
|
159
|
-
* mustUseAttribute:
|
|
160
|
-
* Whether the property must be accessed and mutated using `*Attribute()`.
|
|
161
|
-
* (This includes anything that fails `<propName> in <element>`.)
|
|
162
162
|
* mustUseProperty:
|
|
163
163
|
* Whether the property must be accessed and mutated as an object property.
|
|
164
164
|
* hasSideEffects:
|
|
@@ -207,27 +207,6 @@ var DOMProperty = {
|
|
|
207
207
|
return false;
|
|
208
208
|
},
|
|
209
209
|
|
|
210
|
-
/**
|
|
211
|
-
* Returns the default property value for a DOM property (i.e., not an
|
|
212
|
-
* attribute). Most default values are '' or false, but not all. Worse yet,
|
|
213
|
-
* some (in particular, `type`) vary depending on the type of element.
|
|
214
|
-
*
|
|
215
|
-
* TODO: Is it better to grab all the possible properties when creating an
|
|
216
|
-
* element to avoid having to create the same element twice?
|
|
217
|
-
*/
|
|
218
|
-
getDefaultValueForProperty: function (nodeName, prop) {
|
|
219
|
-
var nodeDefaults = defaultValueCache[nodeName];
|
|
220
|
-
var testElement;
|
|
221
|
-
if (!nodeDefaults) {
|
|
222
|
-
defaultValueCache[nodeName] = nodeDefaults = {};
|
|
223
|
-
}
|
|
224
|
-
if (!(prop in nodeDefaults)) {
|
|
225
|
-
testElement = document.createElement(nodeName);
|
|
226
|
-
nodeDefaults[prop] = testElement[prop];
|
|
227
|
-
}
|
|
228
|
-
return nodeDefaults[prop];
|
|
229
|
-
},
|
|
230
|
-
|
|
231
210
|
injection: DOMPropertyInjection
|
|
232
211
|
};
|
|
233
212
|
|