react 0.14.0-alpha1 → 0.14.0-beta2
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/README.md +5 -2
- package/addons.js +5 -2
- package/dist/JSXTransformer.js +634 -274
- package/dist/react-with-addons.js +5376 -4800
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +5175 -4626
- package/dist/react.min.js +6 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +3 -0
- package/lib/CSSPropertyOperations.js +13 -13
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +16 -14
- package/lib/DOMChildrenOperations.js +10 -6
- package/lib/DOMProperty.js +82 -119
- package/lib/DOMPropertyOperations.js +78 -33
- package/lib/Danger.js +14 -16
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +8 -8
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +13 -13
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +17 -17
- package/lib/EventPropagators.js +7 -7
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +14 -5
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +50 -38
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +14 -2
- package/lib/React.js +9 -111
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +16 -5
- package/lib/ReactCSSTransitionGroupChild.js +20 -11
- package/lib/ReactChildReconciler.js +25 -18
- package/lib/ReactChildren.js +24 -22
- package/lib/ReactClass.js +68 -86
- package/lib/ReactComponent.js +22 -17
- package/lib/ReactComponentBrowserEnvironment.js +2 -4
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +80 -111
- package/lib/ReactDOM.js +72 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +384 -62
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/ReactDOMIDOperations.js +23 -25
- package/lib/ReactDOMInput.js +83 -99
- package/lib/ReactDOMOption.js +38 -42
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +13 -13
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +34 -71
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -9
- package/lib/ReactElement.js +35 -92
- package/lib/ReactElementValidator.js +53 -130
- package/lib/ReactEmptyComponent.js +4 -4
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +57 -12
- package/lib/ReactFragment.js +22 -17
- package/lib/ReactInjection.js +11 -11
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +90 -89
- package/lib/ReactMultiChild.js +83 -22
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -8
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +72 -33
- package/lib/ReactReconcileTransaction.js +8 -8
- package/lib/ReactReconciler.js +18 -20
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +7 -7
- package/lib/ReactTestUtils.js +80 -58
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +61 -36
- package/lib/ReactUpdates.js +14 -17
- package/lib/ReactWithAddons.js +14 -16
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -3
- package/lib/SelectEventPlugin.js +14 -15
- package/lib/SimpleEventPlugin.js +205 -29
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +9 -8
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +3 -3
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +5 -5
- package/lib/SyntheticTouchEvent.js +4 -4
- package/lib/SyntheticUIEvent.js +4 -4
- package/lib/SyntheticWheelEvent.js +3 -3
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +16 -10
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -9
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +47 -0
- package/lib/findDOMNode.js +11 -12
- package/lib/flattenChildren.js +4 -4
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +24 -20
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +210 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +2 -2
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/sliceChildren.js +51 -0
- package/lib/traverseAllChildren.js +24 -27
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +199 -100
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +53 -1
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createFullPageComponent.js +0 -51
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/emptyObject.js +0 -20
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -115
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/isTextNode.js +0 -25
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/performance.js +0 -23
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -61
package/lib/ReactFragment.js
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
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 ReactFragment
|
|
10
|
-
*/
|
|
9
|
+
* @providesModule ReactFragment
|
|
10
|
+
*/
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactElement = require(
|
|
14
|
+
var ReactElement = require('./ReactElement');
|
|
15
15
|
|
|
16
|
-
var warning = require(
|
|
16
|
+
var warning = require('fbjs/lib/warning');
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* We used to allow keyed objects to serve as a collection of ReactElements,
|
|
@@ -23,10 +23,13 @@ var warning = require("./warning");
|
|
|
23
23
|
* create a keyed fragment. The resulting data structure is opaque, for now.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
var fragmentKey;
|
|
27
|
+
var didWarnKey;
|
|
28
|
+
var canWarnForReactFragment;
|
|
29
|
+
|
|
30
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
31
|
+
fragmentKey = '_reactFragment';
|
|
32
|
+
didWarnKey = '_reactDidWarn';
|
|
30
33
|
|
|
31
34
|
try {
|
|
32
35
|
// Feature test. Don't even try to issue this warning if we can't use
|
|
@@ -41,18 +44,20 @@ if ('production' !== process.env.NODE_ENV) {
|
|
|
41
44
|
Object.defineProperty({}, 'key', { enumerable: true, get: dummy });
|
|
42
45
|
|
|
43
46
|
canWarnForReactFragment = true;
|
|
44
|
-
} catch (x) {
|
|
47
|
+
} catch (x) {
|
|
48
|
+
canWarnForReactFragment = false;
|
|
49
|
+
}
|
|
45
50
|
|
|
46
51
|
var proxyPropertyAccessWithWarning = function (obj, key) {
|
|
47
52
|
Object.defineProperty(obj, key, {
|
|
48
53
|
enumerable: true,
|
|
49
54
|
get: function () {
|
|
50
|
-
|
|
55
|
+
process.env.NODE_ENV !== 'production' ? warning(this[didWarnKey], 'A ReactFragment is an opaque type. Accessing any of its ' + 'properties is deprecated. Pass it to one of the React.Children ' + 'helpers.') : undefined;
|
|
51
56
|
this[didWarnKey] = true;
|
|
52
57
|
return this[fragmentKey][key];
|
|
53
58
|
},
|
|
54
59
|
set: function (value) {
|
|
55
|
-
|
|
60
|
+
process.env.NODE_ENV !== 'production' ? warning(this[didWarnKey], 'A ReactFragment is an immutable opaque type. Mutating its ' + 'properties is deprecated.') : undefined;
|
|
56
61
|
this[didWarnKey] = true;
|
|
57
62
|
this[fragmentKey][key] = value;
|
|
58
63
|
}
|
|
@@ -78,13 +83,13 @@ var ReactFragment = {
|
|
|
78
83
|
// Wrap a keyed object in an opaque proxy that warns you if you access any
|
|
79
84
|
// of its properties.
|
|
80
85
|
create: function (object) {
|
|
81
|
-
if (
|
|
86
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
82
87
|
if (typeof object !== 'object' || !object || Array.isArray(object)) {
|
|
83
|
-
|
|
88
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : undefined;
|
|
84
89
|
return object;
|
|
85
90
|
}
|
|
86
91
|
if (ReactElement.isValidElement(object)) {
|
|
87
|
-
|
|
92
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') : undefined;
|
|
88
93
|
return object;
|
|
89
94
|
}
|
|
90
95
|
if (canWarnForReactFragment) {
|
|
@@ -110,10 +115,10 @@ var ReactFragment = {
|
|
|
110
115
|
// Extract the original keyed object from the fragment opaque type. Warn if
|
|
111
116
|
// a plain object is passed here.
|
|
112
117
|
extract: function (fragment) {
|
|
113
|
-
if (
|
|
118
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
114
119
|
if (canWarnForReactFragment) {
|
|
115
120
|
if (!fragment[fragmentKey]) {
|
|
116
|
-
|
|
121
|
+
process.env.NODE_ENV !== 'production' ? warning(didWarnForFragment(fragment), 'Any use of a keyed object should be wrapped in ' + 'React.addons.createFragment(object) before being passed as a ' + 'child.') : undefined;
|
|
117
122
|
return fragment;
|
|
118
123
|
}
|
|
119
124
|
return fragment[fragmentKey];
|
|
@@ -125,7 +130,7 @@ var ReactFragment = {
|
|
|
125
130
|
// is a fragment-like object, warn that it should be wrapped. Ignore if we
|
|
126
131
|
// can't determine what kind of object this is.
|
|
127
132
|
extractIfFragment: function (fragment) {
|
|
128
|
-
if (
|
|
133
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
129
134
|
if (canWarnForReactFragment) {
|
|
130
135
|
// If it is the opaque type, return the keyed object.
|
|
131
136
|
if (fragment[fragmentKey]) {
|
package/lib/ReactInjection.js
CHANGED
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var DOMProperty = require(
|
|
15
|
-
var EventPluginHub = require(
|
|
16
|
-
var ReactComponentEnvironment = require(
|
|
17
|
-
var ReactClass = require(
|
|
18
|
-
var ReactEmptyComponent = require(
|
|
19
|
-
var ReactBrowserEventEmitter = require(
|
|
20
|
-
var ReactNativeComponent = require(
|
|
21
|
-
var ReactDOMComponent = require(
|
|
22
|
-
var ReactPerf = require(
|
|
23
|
-
var ReactRootIndex = require(
|
|
24
|
-
var ReactUpdates = require(
|
|
14
|
+
var DOMProperty = require('./DOMProperty');
|
|
15
|
+
var EventPluginHub = require('./EventPluginHub');
|
|
16
|
+
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
|
|
17
|
+
var ReactClass = require('./ReactClass');
|
|
18
|
+
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
19
|
+
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
20
|
+
var ReactNativeComponent = require('./ReactNativeComponent');
|
|
21
|
+
var ReactDOMComponent = require('./ReactDOMComponent');
|
|
22
|
+
var ReactPerf = require('./ReactPerf');
|
|
23
|
+
var ReactRootIndex = require('./ReactRootIndex');
|
|
24
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
25
25
|
|
|
26
26
|
var ReactInjection = {
|
|
27
27
|
Component: ReactComponentEnvironment.injection,
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactDOMSelection = require(
|
|
14
|
+
var ReactDOMSelection = require('./ReactDOMSelection');
|
|
15
15
|
|
|
16
|
-
var containsNode = require(
|
|
17
|
-
var focusNode = require(
|
|
18
|
-
var getActiveElement = require(
|
|
16
|
+
var containsNode = require('fbjs/lib/containsNode');
|
|
17
|
+
var focusNode = require('fbjs/lib/focusNode');
|
|
18
|
+
var getActiveElement = require('fbjs/lib/getActiveElement');
|
|
19
19
|
|
|
20
20
|
function isInDocument(node) {
|
|
21
21
|
return containsNode(document.documentElement, node);
|
|
@@ -30,7 +30,8 @@ function isInDocument(node) {
|
|
|
30
30
|
var ReactInputSelection = {
|
|
31
31
|
|
|
32
32
|
hasSelectionCapabilities: function (elem) {
|
|
33
|
-
|
|
33
|
+
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
|
34
|
+
return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true');
|
|
34
35
|
},
|
|
35
36
|
|
|
36
37
|
getSelectionInformation: function () {
|
|
@@ -73,7 +74,7 @@ var ReactInputSelection = {
|
|
|
73
74
|
start: input.selectionStart,
|
|
74
75
|
end: input.selectionEnd
|
|
75
76
|
};
|
|
76
|
-
} else if (document.selection && input.nodeName === '
|
|
77
|
+
} else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
|
|
77
78
|
// IE8 input.
|
|
78
79
|
var range = document.selection.createRange();
|
|
79
80
|
// There can only be one selection per document in IE, so it must
|
|
@@ -108,7 +109,7 @@ var ReactInputSelection = {
|
|
|
108
109
|
if ('selectionStart' in input) {
|
|
109
110
|
input.selectionStart = start;
|
|
110
111
|
input.selectionEnd = Math.min(end, input.value.length);
|
|
111
|
-
} else if (document.selection && input.nodeName === '
|
|
112
|
+
} else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
|
|
112
113
|
var range = input.createTextRange();
|
|
113
114
|
range.collapse(true);
|
|
114
115
|
range.moveStart('character', start);
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var ReactRootIndex = require(
|
|
15
|
+
var ReactRootIndex = require('./ReactRootIndex');
|
|
16
16
|
|
|
17
|
-
var invariant = require(
|
|
17
|
+
var invariant = require('fbjs/lib/invariant');
|
|
18
18
|
|
|
19
19
|
var SEPARATOR = '.';
|
|
20
20
|
var SEPARATOR_LENGTH = SEPARATOR.length;
|
|
@@ -22,7 +22,7 @@ var SEPARATOR_LENGTH = SEPARATOR.length;
|
|
|
22
22
|
/**
|
|
23
23
|
* Maximum depth of traversals before we consider the possibility of a bad ID.
|
|
24
24
|
*/
|
|
25
|
-
var MAX_TREE_DEPTH =
|
|
25
|
+
var MAX_TREE_DEPTH = 10000;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Creates a DOM ID prefix to use when mounting React components.
|
|
@@ -91,8 +91,8 @@ function getParentID(id) {
|
|
|
91
91
|
* @private
|
|
92
92
|
*/
|
|
93
93
|
function getNextDescendantID(ancestorID, destinationID) {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
!(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : undefined;
|
|
95
|
+
!isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : undefined;
|
|
96
96
|
if (ancestorID === destinationID) {
|
|
97
97
|
return ancestorID;
|
|
98
98
|
}
|
|
@@ -134,7 +134,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
|
|
137
|
-
|
|
137
|
+
!isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : undefined;
|
|
138
138
|
return longestCommonID;
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -146,6 +146,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
146
146
|
* @param {?string} start ID at which to start traversal.
|
|
147
147
|
* @param {?string} stop ID at which to end traversal.
|
|
148
148
|
* @param {function} cb Callback to invoke each ID with.
|
|
149
|
+
* @param {*} arg Argument to invoke the callback with.
|
|
149
150
|
* @param {?boolean} skipFirst Whether or not to skip the first node.
|
|
150
151
|
* @param {?boolean} skipLast Whether or not to skip the last node.
|
|
151
152
|
* @private
|
|
@@ -153,13 +154,13 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
153
154
|
function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
154
155
|
start = start || '';
|
|
155
156
|
stop = stop || '';
|
|
156
|
-
|
|
157
|
+
!(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : undefined;
|
|
157
158
|
var traverseUp = isAncestorIDOf(stop, start);
|
|
158
|
-
|
|
159
|
+
!(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : undefined;
|
|
159
160
|
// Traverse from `start` to `stop` one depth at a time.
|
|
160
161
|
var depth = 0;
|
|
161
162
|
var traverse = traverseUp ? getParentID : getNextDescendantID;
|
|
162
|
-
for (var id = start;; id = traverse(id, stop)) {
|
|
163
|
+
for (var id = start;; /* until break */id = traverse(id, stop)) {
|
|
163
164
|
var ret;
|
|
164
165
|
if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
|
|
165
166
|
ret = cb(id, traverseUp, arg);
|
|
@@ -168,7 +169,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
|
168
169
|
// Only break //after// visiting `stop`.
|
|
169
170
|
break;
|
|
170
171
|
}
|
|
171
|
-
|
|
172
|
+
!(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : undefined;
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
|
|
@@ -298,5 +299,4 @@ var ReactInstanceHandles = {
|
|
|
298
299
|
|
|
299
300
|
};
|
|
300
301
|
|
|
301
|
-
module.exports = ReactInstanceHandles;
|
|
302
|
-
/* until break */
|
|
302
|
+
module.exports = ReactInstanceHandles;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2015, 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 ReactIsomorphic
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactChildren = require('./ReactChildren');
|
|
15
|
+
var ReactComponent = require('./ReactComponent');
|
|
16
|
+
var ReactClass = require('./ReactClass');
|
|
17
|
+
var ReactDOMFactories = require('./ReactDOMFactories');
|
|
18
|
+
var ReactElement = require('./ReactElement');
|
|
19
|
+
var ReactElementValidator = require('./ReactElementValidator');
|
|
20
|
+
var ReactPropTypes = require('./ReactPropTypes');
|
|
21
|
+
|
|
22
|
+
var assign = require('./Object.assign');
|
|
23
|
+
var onlyChild = require('./onlyChild');
|
|
24
|
+
|
|
25
|
+
var createElement = ReactElement.createElement;
|
|
26
|
+
var createFactory = ReactElement.createFactory;
|
|
27
|
+
var cloneElement = ReactElement.cloneElement;
|
|
28
|
+
|
|
29
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
30
|
+
createElement = ReactElementValidator.createElement;
|
|
31
|
+
createFactory = ReactElementValidator.createFactory;
|
|
32
|
+
cloneElement = ReactElementValidator.cloneElement;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var React = {
|
|
36
|
+
|
|
37
|
+
// Modern
|
|
38
|
+
|
|
39
|
+
Children: {
|
|
40
|
+
map: ReactChildren.map,
|
|
41
|
+
forEach: ReactChildren.forEach,
|
|
42
|
+
count: ReactChildren.count,
|
|
43
|
+
only: onlyChild
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
Component: ReactComponent,
|
|
47
|
+
|
|
48
|
+
createElement: createElement,
|
|
49
|
+
cloneElement: cloneElement,
|
|
50
|
+
isValidElement: ReactElement.isValidElement,
|
|
51
|
+
|
|
52
|
+
// Classic
|
|
53
|
+
|
|
54
|
+
PropTypes: ReactPropTypes,
|
|
55
|
+
createClass: ReactClass.createClass,
|
|
56
|
+
createFactory: createFactory,
|
|
57
|
+
createMixin: function (mixin) {
|
|
58
|
+
// Currently a noop. Will be used to validate and trace mixins.
|
|
59
|
+
return mixin;
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// This looks DOM specific but these are actually isomorphic helpers
|
|
63
|
+
// since they are just generating DOM strings.
|
|
64
|
+
DOM: ReactDOMFactories,
|
|
65
|
+
|
|
66
|
+
// Hook for JSX spread, don't use this for anything else.
|
|
67
|
+
__spread: assign
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
module.exports = React;
|
package/lib/ReactLink.js
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var adler32 = require(
|
|
14
|
+
var adler32 = require('./adler32');
|
|
15
|
+
|
|
16
|
+
var TAG_END = /\/?>/;
|
|
15
17
|
|
|
16
18
|
var ReactMarkupChecksum = {
|
|
17
19
|
CHECKSUM_ATTR_NAME: 'data-react-checksum',
|
|
@@ -22,7 +24,9 @@ var ReactMarkupChecksum = {
|
|
|
22
24
|
*/
|
|
23
25
|
addChecksumToMarkup: function (markup) {
|
|
24
26
|
var checksum = adler32(markup);
|
|
25
|
-
|
|
27
|
+
|
|
28
|
+
// Add checksum (handle both parent tags and self-closing tags)
|
|
29
|
+
return markup.replace(TAG_END, ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&');
|
|
26
30
|
},
|
|
27
31
|
|
|
28
32
|
/**
|
package/lib/ReactMount.js
CHANGED
|
@@ -11,28 +11,27 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var DOMProperty = require(
|
|
15
|
-
var ReactBrowserEventEmitter = require(
|
|
16
|
-
var ReactCurrentOwner = require(
|
|
17
|
-
var ReactElement = require(
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var warning = require("./warning");
|
|
14
|
+
var DOMProperty = require('./DOMProperty');
|
|
15
|
+
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
16
|
+
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
17
|
+
var ReactElement = require('./ReactElement');
|
|
18
|
+
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
19
|
+
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
20
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
21
|
+
var ReactMarkupChecksum = require('./ReactMarkupChecksum');
|
|
22
|
+
var ReactPerf = require('./ReactPerf');
|
|
23
|
+
var ReactReconciler = require('./ReactReconciler');
|
|
24
|
+
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
25
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
26
|
+
|
|
27
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
28
|
+
var containsNode = require('fbjs/lib/containsNode');
|
|
29
|
+
var instantiateReactComponent = require('./instantiateReactComponent');
|
|
30
|
+
var invariant = require('fbjs/lib/invariant');
|
|
31
|
+
var setInnerHTML = require('./setInnerHTML');
|
|
32
|
+
var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
|
|
33
|
+
var validateDOMNesting = require('./validateDOMNesting');
|
|
34
|
+
var warning = require('fbjs/lib/warning');
|
|
36
35
|
|
|
37
36
|
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
|
|
38
37
|
|
|
@@ -49,7 +48,7 @@ var instancesByReactRootID = {};
|
|
|
49
48
|
/** Mapping from reactRootID to `container` nodes. */
|
|
50
49
|
var containersByReactRootID = {};
|
|
51
50
|
|
|
52
|
-
if (
|
|
51
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
53
52
|
/** __DEV__-only mapping from reactRootID to root elements. */
|
|
54
53
|
var rootElementsByReactRootID = {};
|
|
55
54
|
}
|
|
@@ -115,7 +114,7 @@ function getID(node) {
|
|
|
115
114
|
if (nodeCache.hasOwnProperty(id)) {
|
|
116
115
|
var cached = nodeCache[id];
|
|
117
116
|
if (cached !== node) {
|
|
118
|
-
|
|
117
|
+
!!isValid(cached, id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Two valid but unequal nodes with the same `%s`: %s', ATTR_NAME, id) : invariant(false) : undefined;
|
|
119
118
|
|
|
120
119
|
nodeCache[id] = node;
|
|
121
120
|
}
|
|
@@ -193,7 +192,7 @@ function getNodeFromInstance(instance) {
|
|
|
193
192
|
*/
|
|
194
193
|
function isValid(node, id) {
|
|
195
194
|
if (node) {
|
|
196
|
-
|
|
195
|
+
!(internalGetID(node) === id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(false) : undefined;
|
|
197
196
|
|
|
198
197
|
var container = ReactMount.findReactContainerForID(id);
|
|
199
198
|
if (container && containsNode(container, node)) {
|
|
@@ -247,14 +246,15 @@ function findDeepestCachedAncestor(targetID) {
|
|
|
247
246
|
* @param {boolean} shouldReuseMarkup If true, do not insert markup
|
|
248
247
|
*/
|
|
249
248
|
function mountComponentIntoNode(componentInstance, rootID, container, transaction, shouldReuseMarkup, context) {
|
|
250
|
-
if (
|
|
249
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
251
250
|
if (context === emptyObject) {
|
|
252
251
|
context = {};
|
|
253
252
|
}
|
|
254
|
-
|
|
253
|
+
var tag = container.nodeName.toLowerCase();
|
|
254
|
+
context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null);
|
|
255
255
|
}
|
|
256
256
|
var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);
|
|
257
|
-
componentInstance.
|
|
257
|
+
componentInstance._renderedComponent._topLevelWrapper = componentInstance;
|
|
258
258
|
ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
|
|
259
259
|
}
|
|
260
260
|
|
|
@@ -294,6 +294,17 @@ function unmountComponentFromNode(instance, container) {
|
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Temporary (?) hack so that we can store all top-level pending updates on
|
|
299
|
+
* composites instead of having to worry about different types of components
|
|
300
|
+
* here.
|
|
301
|
+
*/
|
|
302
|
+
var TopLevelWrapper = function () {};
|
|
303
|
+
TopLevelWrapper.prototype.render = function () {
|
|
304
|
+
// this.props is actually a ReactElement
|
|
305
|
+
return this.props;
|
|
306
|
+
};
|
|
307
|
+
|
|
297
308
|
/**
|
|
298
309
|
* Mounting is the process of initializing a React component by creating its
|
|
299
310
|
* representative DOM elements and inserting them into a supplied `container`.
|
|
@@ -336,10 +347,6 @@ var ReactMount = {
|
|
|
336
347
|
* @param {?function} callback function triggered on completion
|
|
337
348
|
*/
|
|
338
349
|
_updateRootComponent: function (prevComponent, nextElement, container, callback) {
|
|
339
|
-
if ('production' !== process.env.NODE_ENV) {
|
|
340
|
-
ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
350
|
ReactMount.scrollMonitor(container, function () {
|
|
344
351
|
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
|
|
345
352
|
if (callback) {
|
|
@@ -347,7 +354,7 @@ var ReactMount = {
|
|
|
347
354
|
}
|
|
348
355
|
});
|
|
349
356
|
|
|
350
|
-
if (
|
|
357
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
351
358
|
// Record the root element in case it later gets transplanted.
|
|
352
359
|
rootElementsByReactRootID[getReactRootID(container)] = getReactRootElementInContainer(container);
|
|
353
360
|
}
|
|
@@ -363,7 +370,7 @@ var ReactMount = {
|
|
|
363
370
|
* @return {string} reactRoot ID prefix
|
|
364
371
|
*/
|
|
365
372
|
_registerComponent: function (nextComponent, container) {
|
|
366
|
-
|
|
373
|
+
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : invariant(false) : undefined;
|
|
367
374
|
|
|
368
375
|
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
|
|
369
376
|
|
|
@@ -383,7 +390,7 @@ var ReactMount = {
|
|
|
383
390
|
// Various parts of our code (such as ReactCompositeComponent's
|
|
384
391
|
// _renderValidatedComponent) assume that calls to render aren't nested;
|
|
385
392
|
// verify that that's the case.
|
|
386
|
-
|
|
393
|
+
process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
|
|
387
394
|
|
|
388
395
|
var componentInstance = instantiateReactComponent(nextElement, null);
|
|
389
396
|
var reactRootID = ReactMount._registerComponent(componentInstance, container);
|
|
@@ -394,7 +401,7 @@ var ReactMount = {
|
|
|
394
401
|
|
|
395
402
|
ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, reactRootID, container, shouldReuseMarkup, context);
|
|
396
403
|
|
|
397
|
-
if (
|
|
404
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
398
405
|
// Record the root element in case it later gets transplanted.
|
|
399
406
|
rootElementsByReactRootID[reactRootID] = getReactRootElementInContainer(container);
|
|
400
407
|
}
|
|
@@ -416,23 +423,26 @@ var ReactMount = {
|
|
|
416
423
|
* @return {ReactComponent} Component instance rendered in `container`.
|
|
417
424
|
*/
|
|
418
425
|
renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
|
|
419
|
-
|
|
426
|
+
!(parentComponent != null && parentComponent._reactInternalInstance != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : undefined;
|
|
420
427
|
return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
|
|
421
428
|
},
|
|
422
429
|
|
|
423
430
|
_renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
|
|
424
|
-
|
|
431
|
+
!ReactElement.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing an element string, make sure to instantiate ' + 'it by passing it to React.createElement.' : typeof nextElement === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' :
|
|
425
432
|
// Check if it quacks like an element
|
|
426
|
-
nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(
|
|
433
|
+
nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : undefined;
|
|
427
434
|
|
|
428
|
-
|
|
435
|
+
process.env.NODE_ENV !== 'production' ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : undefined;
|
|
436
|
+
|
|
437
|
+
var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, nextElement);
|
|
429
438
|
|
|
430
439
|
var prevComponent = instancesByReactRootID[getReactRootID(container)];
|
|
431
440
|
|
|
432
441
|
if (prevComponent) {
|
|
433
|
-
var
|
|
442
|
+
var prevWrappedElement = prevComponent._currentElement;
|
|
443
|
+
var prevElement = prevWrappedElement.props;
|
|
434
444
|
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
435
|
-
return ReactMount._updateRootComponent(prevComponent,
|
|
445
|
+
return ReactMount._updateRootComponent(prevComponent, nextWrappedElement, container, callback)._renderedComponent.getPublicInstance();
|
|
436
446
|
} else {
|
|
437
447
|
ReactMount.unmountComponentAtNode(container);
|
|
438
448
|
}
|
|
@@ -441,12 +451,12 @@ var ReactMount = {
|
|
|
441
451
|
var reactRootElement = getReactRootElementInContainer(container);
|
|
442
452
|
var containerHasReactMarkup = reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
|
|
443
453
|
|
|
444
|
-
if (
|
|
454
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
445
455
|
if (!containerHasReactMarkup || reactRootElement.nextSibling) {
|
|
446
456
|
var rootElementSibling = reactRootElement;
|
|
447
457
|
while (rootElementSibling) {
|
|
448
458
|
if (ReactMount.isRenderedByReact(rootElementSibling)) {
|
|
449
|
-
|
|
459
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.') : undefined;
|
|
450
460
|
break;
|
|
451
461
|
}
|
|
452
462
|
|
|
@@ -456,7 +466,7 @@ var ReactMount = {
|
|
|
456
466
|
}
|
|
457
467
|
|
|
458
468
|
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
|
|
459
|
-
var component = ReactMount._renderNewRootComponent(
|
|
469
|
+
var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, parentComponent != null ? parentComponent._reactInternalInstance._processChildContext(parentComponent._reactInternalInstance._context) : emptyObject)._renderedComponent.getPublicInstance();
|
|
460
470
|
if (callback) {
|
|
461
471
|
callback.call(component);
|
|
462
472
|
}
|
|
@@ -479,35 +489,6 @@ var ReactMount = {
|
|
|
479
489
|
return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback);
|
|
480
490
|
},
|
|
481
491
|
|
|
482
|
-
/**
|
|
483
|
-
* Constructs a component instance of `constructor` with `initialProps` and
|
|
484
|
-
* renders it into the supplied `container`.
|
|
485
|
-
*
|
|
486
|
-
* @param {function} constructor React component constructor.
|
|
487
|
-
* @param {?object} props Initial props of the component instance.
|
|
488
|
-
* @param {DOMElement} container DOM element to render into.
|
|
489
|
-
* @return {ReactComponent} Component instance rendered in `container`.
|
|
490
|
-
*/
|
|
491
|
-
constructAndRenderComponent: function (constructor, props, container) {
|
|
492
|
-
var element = ReactElement.createElement(constructor, props);
|
|
493
|
-
return ReactMount.render(element, container);
|
|
494
|
-
},
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Constructs a component instance of `constructor` with `initialProps` and
|
|
498
|
-
* renders it into a container node identified by supplied `id`.
|
|
499
|
-
*
|
|
500
|
-
* @param {function} componentConstructor React component constructor
|
|
501
|
-
* @param {?object} props Initial props of the component instance.
|
|
502
|
-
* @param {string} id ID of the DOM element to render into.
|
|
503
|
-
* @return {ReactComponent} Component instance rendered in the container node.
|
|
504
|
-
*/
|
|
505
|
-
constructAndRenderComponentByID: function (constructor, props, id) {
|
|
506
|
-
var domNode = document.getElementById(id);
|
|
507
|
-
'production' !== process.env.NODE_ENV ? invariant(domNode, 'Tried to get element with id of "%s" but it is not present on the page.', id) : invariant(domNode);
|
|
508
|
-
return ReactMount.constructAndRenderComponent(constructor, props, domNode);
|
|
509
|
-
},
|
|
510
|
-
|
|
511
492
|
/**
|
|
512
493
|
* Registers a container node into which React components will be rendered.
|
|
513
494
|
* This also creates the "reactRoot" ID that will be assigned to the element
|
|
@@ -542,9 +523,9 @@ var ReactMount = {
|
|
|
542
523
|
// _renderValidatedComponent) assume that calls to render aren't nested;
|
|
543
524
|
// verify that that's the case. (Strictly speaking, unmounting won't cause a
|
|
544
525
|
// render but we still don't expect to be in a render call here.)
|
|
545
|
-
|
|
526
|
+
process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
|
|
546
527
|
|
|
547
|
-
|
|
528
|
+
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(false) : undefined;
|
|
548
529
|
|
|
549
530
|
var reactRootID = getReactRootID(container);
|
|
550
531
|
var component = instancesByReactRootID[reactRootID];
|
|
@@ -554,7 +535,7 @@ var ReactMount = {
|
|
|
554
535
|
ReactUpdates.batchedUpdates(unmountComponentFromNode, component, container);
|
|
555
536
|
delete instancesByReactRootID[reactRootID];
|
|
556
537
|
delete containersByReactRootID[reactRootID];
|
|
557
|
-
if (
|
|
538
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
558
539
|
delete rootElementsByReactRootID[reactRootID];
|
|
559
540
|
}
|
|
560
541
|
return true;
|
|
@@ -571,13 +552,13 @@ var ReactMount = {
|
|
|
571
552
|
var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
|
|
572
553
|
var container = containersByReactRootID[reactRootID];
|
|
573
554
|
|
|
574
|
-
if (
|
|
555
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
575
556
|
var rootElement = rootElementsByReactRootID[reactRootID];
|
|
576
557
|
if (rootElement && rootElement.parentNode !== container) {
|
|
577
|
-
|
|
558
|
+
process.env.NODE_ENV !== 'production' ? warning(
|
|
578
559
|
// Call internalGetID here because getID calls isValid which calls
|
|
579
560
|
// findReactContainerForID (this function).
|
|
580
|
-
internalGetID(rootElement) === reactRootID, 'ReactMount: Root element ID differed from reactRootID.') :
|
|
561
|
+
internalGetID(rootElement) === reactRootID, 'ReactMount: Root element ID differed from reactRootID.') : undefined;
|
|
581
562
|
var containerChild = container.firstChild;
|
|
582
563
|
if (containerChild && reactRootID === internalGetID(containerChild)) {
|
|
583
564
|
// If the container has a new child with the same ID as the old
|
|
@@ -586,7 +567,7 @@ var ReactMount = {
|
|
|
586
567
|
// warning is when the container is empty.
|
|
587
568
|
rootElementsByReactRootID[reactRootID] = containerChild;
|
|
588
569
|
} else {
|
|
589
|
-
|
|
570
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container: %s', rootElement.parentNode) : undefined;
|
|
590
571
|
}
|
|
591
572
|
}
|
|
592
573
|
}
|
|
@@ -705,11 +686,11 @@ var ReactMount = {
|
|
|
705
686
|
|
|
706
687
|
firstChildren.length = 0;
|
|
707
688
|
|
|
708
|
-
|
|
689
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findComponentRoot(..., %s): Unable to find 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`.', targetID, ReactMount.getID(ancestorNode)) : invariant(false) : undefined;
|
|
709
690
|
},
|
|
710
691
|
|
|
711
692
|
_mountImageIntoNode: function (markup, container, shouldReuseMarkup) {
|
|
712
|
-
|
|
693
|
+
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : invariant(false) : undefined;
|
|
713
694
|
|
|
714
695
|
if (shouldReuseMarkup) {
|
|
715
696
|
var rootElement = getReactRootElementInContainer(container);
|
|
@@ -722,18 +703,38 @@ var ReactMount = {
|
|
|
722
703
|
var rootMarkup = rootElement.outerHTML;
|
|
723
704
|
rootElement.setAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME, checksum);
|
|
724
705
|
|
|
725
|
-
var
|
|
726
|
-
|
|
706
|
+
var normalizedMarkup = markup;
|
|
707
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
708
|
+
// because rootMarkup is retrieved from the DOM, various normalizations
|
|
709
|
+
// will have occurred which will not be present in `markup`. Here,
|
|
710
|
+
// insert markup into a <div> or <iframe> depending on the container
|
|
711
|
+
// type to perform the same normalizations before comparing.
|
|
712
|
+
var normalizer;
|
|
713
|
+
if (container.nodeType === ELEMENT_NODE_TYPE) {
|
|
714
|
+
normalizer = document.createElement('div');
|
|
715
|
+
normalizer.innerHTML = markup;
|
|
716
|
+
normalizedMarkup = normalizer.innerHTML;
|
|
717
|
+
} else {
|
|
718
|
+
normalizer = document.createElement('iframe');
|
|
719
|
+
document.body.appendChild(normalizer);
|
|
720
|
+
normalizer.contentDocument.write(markup);
|
|
721
|
+
normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
|
|
722
|
+
document.body.removeChild(normalizer);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
|
|
727
|
+
var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
|
|
727
728
|
|
|
728
|
-
|
|
729
|
+
!(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document using ' + 'server rendering but the checksum was invalid. This usually ' + 'means you rendered a different component type or props on ' + 'the client from the one on the server, or your render() ' + 'methods are impure. React cannot handle this case due to ' + 'cross-browser quirks by rendering at the document root. You ' + 'should look for environment dependent code in your components ' + 'and ensure the props are the same client and server side:\n%s', difference) : invariant(false) : undefined;
|
|
729
730
|
|
|
730
|
-
if (
|
|
731
|
-
|
|
731
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
732
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'React attempted to reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + 'or server:\n%s', difference) : undefined;
|
|
732
733
|
}
|
|
733
734
|
}
|
|
734
735
|
}
|
|
735
736
|
|
|
736
|
-
|
|
737
|
+
!(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document but ' + 'you didn\'t use server rendering. We can\'t do this ' + 'without using server rendering due to cross-browser quirks. ' + 'See React.renderToString() for server rendering.') : invariant(false) : undefined;
|
|
737
738
|
|
|
738
739
|
setInnerHTML(container, markup);
|
|
739
740
|
},
|