react 0.14.7 → 0.15.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/react-with-addons.js +2937 -3414
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +2762 -3034
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +3 -1
- package/lib/CSSPropertyOperations.js +20 -6
- package/lib/CallbackQueue.js +12 -1
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +21 -60
- package/lib/DOMLazyTree.js +95 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +7 -2
- package/lib/DOMPropertyOperations.js +66 -36
- package/lib/Danger.js +6 -7
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +2 -1
- package/lib/EventPluginHub.js +15 -59
- package/lib/EventPluginRegistry.js +23 -2
- package/lib/EventPluginUtils.js +60 -35
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +1 -2
- package/lib/HTMLDOMPropertyConfig.js +21 -23
- package/lib/LinkedInput.js +49 -0
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +1 -2
- package/lib/MetaMatchers.js +2 -2
- package/lib/Object.assign.js +1 -1
- package/lib/OrderedMap.js +1 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +1 -13
- package/lib/ReactBrowserEventEmitter.js +3 -23
- package/lib/ReactCSSTransitionGroup.js +1 -2
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +12 -10
- package/lib/ReactChildren.js +3 -3
- package/lib/ReactClass.js +18 -67
- package/lib/ReactComponent.js +2 -5
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +3 -3
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +94 -29
- package/lib/ReactCurrentOwner.js +1 -1
- package/lib/ReactDOM.js +26 -14
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +156 -218
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +69 -0
- package/lib/ReactDOMEmptyComponent.js +61 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +52 -23
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +9 -8
- package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +57 -0
- package/lib/ReactDOMSelect.js +35 -14
- package/lib/ReactDOMSelection.js +2 -2
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +41 -21
- package/lib/ReactDOMTextarea.js +32 -5
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +49 -19
- package/lib/ReactDefaultPerfAnalysis.js +16 -9
- package/lib/ReactElement.js +9 -5
- package/lib/ReactElementValidator.js +1 -1
- package/lib/ReactEmptyComponent.js +8 -29
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +20 -75
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +2 -2
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +3 -3
- package/lib/ReactInstanceHandles.js +4 -6
- package/lib/ReactInstanceMap.js +1 -1
- package/lib/ReactIsomorphic.js +1 -1
- package/lib/ReactLink.js +1 -2
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +67 -445
- package/lib/ReactMultiChild.js +104 -198
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +1 -1
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +1 -24
- package/lib/ReactOwner.js +1 -1
- package/lib/ReactPerf.js +1 -2
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +8 -2
- package/lib/ReactReconcileTransaction.js +17 -6
- package/lib/ReactReconciler.js +14 -5
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +15 -33
- package/lib/ReactServerRenderingTransaction.js +8 -26
- package/lib/ReactSimpleEmptyComponent.js +37 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +25 -15
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +1 -1
- package/lib/ReactUpdateQueue.js +4 -4
- package/lib/ReactUpdates.js +19 -2
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -3
- package/lib/ResponderEventPlugin.js +53 -65
- package/lib/ResponderSyntheticEvent.js +1 -2
- package/lib/ResponderTouchHistoryStore.js +1 -1
- package/lib/SVGDOMPropertyConfig.js +2 -39
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +18 -16
- package/lib/SyntheticClipboardEvent.js +1 -2
- package/lib/SyntheticCompositionEvent.js +1 -2
- package/lib/SyntheticDragEvent.js +1 -2
- package/lib/SyntheticEvent.js +10 -7
- package/lib/SyntheticFocusEvent.js +1 -2
- package/lib/SyntheticInputEvent.js +1 -2
- package/lib/SyntheticKeyboardEvent.js +1 -2
- package/lib/SyntheticMouseEvent.js +1 -2
- package/lib/SyntheticTouchEvent.js +1 -2
- package/lib/SyntheticUIEvent.js +1 -2
- package/lib/SyntheticWheelEvent.js +1 -2
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +1 -1
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +1 -1
- package/lib/accumulateInto.js +1 -1
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +1 -1
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +1 -2
- package/lib/getIteratorFn.js +1 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +3 -4
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +1 -1
- package/lib/onlyChild.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +1 -1
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +1 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +6 -6
- package/lib/update.js +1 -1
- package/lib/validateDOMNesting.js +8 -9
- package/package.json +2 -2
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
package/lib/ReactCurrentOwner.js
CHANGED
package/lib/ReactDOM.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
|
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
var
|
|
17
|
-
var ReactDOMTextComponent = require('./ReactDOMTextComponent');
|
|
16
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
18
17
|
var ReactDefaultInjection = require('./ReactDefaultInjection');
|
|
19
|
-
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
20
18
|
var ReactMount = require('./ReactMount');
|
|
21
19
|
var ReactPerf = require('./ReactPerf');
|
|
22
20
|
var ReactReconciler = require('./ReactReconciler');
|
|
@@ -24,6 +22,7 @@ var ReactUpdates = require('./ReactUpdates');
|
|
|
24
22
|
var ReactVersion = require('./ReactVersion');
|
|
25
23
|
|
|
26
24
|
var findDOMNode = require('./findDOMNode');
|
|
25
|
+
var getNativeComponentFromComposite = require('./getNativeComponentFromComposite');
|
|
27
26
|
var renderSubtreeIntoContainer = require('./renderSubtreeIntoContainer');
|
|
28
27
|
var warning = require('fbjs/lib/warning');
|
|
29
28
|
|
|
@@ -47,11 +46,22 @@ var React = {
|
|
|
47
46
|
/* eslint-enable camelcase */
|
|
48
47
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
|
|
49
48
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
ComponentTree: {
|
|
50
|
+
getClosestInstanceFromNode: ReactDOMComponentTree.getClosestInstanceFromNode,
|
|
51
|
+
getNodeFromInstance: function (inst) {
|
|
52
|
+
// inst is an internal instance (but could be a composite)
|
|
53
|
+
if (inst._renderedComponent) {
|
|
54
|
+
inst = getNativeComponentFromComposite(inst);
|
|
55
|
+
}
|
|
56
|
+
if (inst) {
|
|
57
|
+
return ReactDOMComponentTree.getNodeFromInstance(inst);
|
|
58
|
+
} else {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
52
63
|
Mount: ReactMount,
|
|
53
|
-
Reconciler: ReactReconciler
|
|
54
|
-
TextComponent: ReactDOMTextComponent
|
|
64
|
+
Reconciler: ReactReconciler
|
|
55
65
|
});
|
|
56
66
|
}
|
|
57
67
|
|
|
@@ -63,10 +73,15 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
63
73
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
|
|
64
74
|
// If we're in Chrome or Firefox, provide a download link if not installed.
|
|
65
75
|
if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
|
|
66
|
-
|
|
76
|
+
// Firefox does not have the issue with devtools loaded over file://
|
|
77
|
+
var showFileUrlMessage = window.location.protocol.indexOf('http') === -1 && navigator.userAgent.indexOf('Firefox') === -1;
|
|
78
|
+
console.debug('Download the React DevTools ' + (showFileUrlMessage ? 'and use an HTTP server (instead of a file: URL) ' : '') + 'for a better development experience: ' + 'https://fb.me/react-devtools');
|
|
67
79
|
}
|
|
68
80
|
}
|
|
69
81
|
|
|
82
|
+
var testFunc = function testFn() {};
|
|
83
|
+
process.env.NODE_ENV !== 'production' ? warning((testFunc.name || testFunc.toString()).indexOf('testFn') !== -1, 'It looks like you\'re using a minified copy of the development build ' + 'of React. When deploying React apps to production, make sure to use ' + 'the production build which skips development warnings and is faster. ' + 'See https://fb.me/react-minification for more details.') : undefined;
|
|
84
|
+
|
|
70
85
|
// If we're in IE8, check to see if we are in compatibility mode and provide
|
|
71
86
|
// information on preventing compatibility mode
|
|
72
87
|
var ieCompatibilityMode = document.documentMode && document.documentMode < 8;
|
|
@@ -75,14 +90,11 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
75
90
|
|
|
76
91
|
var expectedFeatures = [
|
|
77
92
|
// shims
|
|
78
|
-
Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.split, String.prototype.trim
|
|
79
|
-
|
|
80
|
-
// shams
|
|
81
|
-
Object.create, Object.freeze];
|
|
93
|
+
Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.split, String.prototype.trim];
|
|
82
94
|
|
|
83
95
|
for (var i = 0; i < expectedFeatures.length; i++) {
|
|
84
96
|
if (!expectedFeatures[i]) {
|
|
85
|
-
|
|
97
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'One or more ES5 shims expected by React are not available: ' + 'https://fb.me/react-warning-polyfills') : undefined;
|
|
86
98
|
break;
|
|
87
99
|
}
|
|
88
100
|
}
|
package/lib/ReactDOMButton.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
|
|
@@ -30,7 +30,7 @@ var mouseListenerNames = {
|
|
|
30
30
|
* when `disabled` is set.
|
|
31
31
|
*/
|
|
32
32
|
var ReactDOMButton = {
|
|
33
|
-
getNativeProps: function (inst, props
|
|
33
|
+
getNativeProps: function (inst, props) {
|
|
34
34
|
if (!props.disabled) {
|
|
35
35
|
return props;
|
|
36
36
|
}
|
package/lib/ReactDOMComponent.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 ReactDOMComponent
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
/* global hasOwnProperty:true */
|
|
@@ -16,36 +15,39 @@
|
|
|
16
15
|
|
|
17
16
|
var AutoFocusUtils = require('./AutoFocusUtils');
|
|
18
17
|
var CSSPropertyOperations = require('./CSSPropertyOperations');
|
|
18
|
+
var DOMLazyTree = require('./DOMLazyTree');
|
|
19
|
+
var DOMNamespaces = require('./DOMNamespaces');
|
|
19
20
|
var DOMProperty = require('./DOMProperty');
|
|
20
21
|
var DOMPropertyOperations = require('./DOMPropertyOperations');
|
|
21
22
|
var EventConstants = require('./EventConstants');
|
|
23
|
+
var EventPluginHub = require('./EventPluginHub');
|
|
24
|
+
var EventPluginRegistry = require('./EventPluginRegistry');
|
|
22
25
|
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
23
26
|
var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
|
|
24
27
|
var ReactDOMButton = require('./ReactDOMButton');
|
|
28
|
+
var ReactDOMComponentFlags = require('./ReactDOMComponentFlags');
|
|
29
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
25
30
|
var ReactDOMInput = require('./ReactDOMInput');
|
|
26
31
|
var ReactDOMOption = require('./ReactDOMOption');
|
|
27
32
|
var ReactDOMSelect = require('./ReactDOMSelect');
|
|
28
33
|
var ReactDOMTextarea = require('./ReactDOMTextarea');
|
|
29
|
-
var ReactMount = require('./ReactMount');
|
|
30
34
|
var ReactMultiChild = require('./ReactMultiChild');
|
|
31
35
|
var ReactPerf = require('./ReactPerf');
|
|
32
|
-
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
33
36
|
|
|
34
37
|
var assign = require('./Object.assign');
|
|
35
|
-
var canDefineProperty = require('./canDefineProperty');
|
|
36
38
|
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
|
|
37
39
|
var invariant = require('fbjs/lib/invariant');
|
|
38
40
|
var isEventSupported = require('./isEventSupported');
|
|
39
41
|
var keyOf = require('fbjs/lib/keyOf');
|
|
40
|
-
var setInnerHTML = require('./setInnerHTML');
|
|
41
|
-
var setTextContent = require('./setTextContent');
|
|
42
42
|
var shallowEqual = require('fbjs/lib/shallowEqual');
|
|
43
43
|
var validateDOMNesting = require('./validateDOMNesting');
|
|
44
44
|
var warning = require('fbjs/lib/warning');
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var Flags = ReactDOMComponentFlags;
|
|
47
|
+
var deleteListener = EventPluginHub.deleteListener;
|
|
48
|
+
var getNode = ReactDOMComponentTree.getNodeFromInstance;
|
|
47
49
|
var listenTo = ReactBrowserEventEmitter.listenTo;
|
|
48
|
-
var registrationNameModules =
|
|
50
|
+
var registrationNameModules = EventPluginRegistry.registrationNameModules;
|
|
49
51
|
|
|
50
52
|
// For quickly matching children type, to test if can be treated as content.
|
|
51
53
|
var CONTENT_TYPES = { 'string': true, 'number': true };
|
|
@@ -54,8 +56,6 @@ var CHILDREN = keyOf({ children: null });
|
|
|
54
56
|
var STYLE = keyOf({ style: null });
|
|
55
57
|
var HTML = keyOf({ __html: null });
|
|
56
58
|
|
|
57
|
-
var ELEMENT_NODE_TYPE = 1;
|
|
58
|
-
|
|
59
59
|
function getDeclarationErrorAddendum(internalInstance) {
|
|
60
60
|
if (internalInstance) {
|
|
61
61
|
var owner = internalInstance._currentElement._owner || null;
|
|
@@ -69,71 +69,6 @@ function getDeclarationErrorAddendum(internalInstance) {
|
|
|
69
69
|
return '';
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
var legacyPropsDescriptor;
|
|
73
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
74
|
-
legacyPropsDescriptor = {
|
|
75
|
-
props: {
|
|
76
|
-
enumerable: false,
|
|
77
|
-
get: function () {
|
|
78
|
-
var component = this._reactInternalComponent;
|
|
79
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .props of a DOM node; instead, ' + 'recreate the props as `render` did originally or read the DOM ' + 'properties/attributes directly from this node (e.g., ' + 'this.refs.box.className).%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
80
|
-
return component._currentElement.props;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function legacyGetDOMNode() {
|
|
87
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
88
|
-
var component = this._reactInternalComponent;
|
|
89
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .getDOMNode() of a DOM node; ' + 'instead, use the node directly.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
90
|
-
}
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function legacyIsMounted() {
|
|
95
|
-
var component = this._reactInternalComponent;
|
|
96
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
97
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .isMounted() of a DOM node.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
98
|
-
}
|
|
99
|
-
return !!component;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function legacySetStateEtc() {
|
|
103
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
104
|
-
var component = this._reactInternalComponent;
|
|
105
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setState(), .replaceState(), or ' + '.forceUpdate() of a DOM node. This is a no-op.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function legacySetProps(partialProps, callback) {
|
|
110
|
-
var component = this._reactInternalComponent;
|
|
111
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
112
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
113
|
-
}
|
|
114
|
-
if (!component) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
ReactUpdateQueue.enqueueSetPropsInternal(component, partialProps);
|
|
118
|
-
if (callback) {
|
|
119
|
-
ReactUpdateQueue.enqueueCallbackInternal(component, callback);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function legacyReplaceProps(partialProps, callback) {
|
|
124
|
-
var component = this._reactInternalComponent;
|
|
125
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
126
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .replaceProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
127
|
-
}
|
|
128
|
-
if (!component) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
ReactUpdateQueue.enqueueReplacePropsInternal(component, partialProps);
|
|
132
|
-
if (callback) {
|
|
133
|
-
ReactUpdateQueue.enqueueCallbackInternal(component, callback);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
72
|
function friendlyStringify(obj) {
|
|
138
73
|
if (typeof obj === 'object') {
|
|
139
74
|
if (Array.isArray(obj)) {
|
|
@@ -153,7 +88,7 @@ function friendlyStringify(obj) {
|
|
|
153
88
|
} else if (typeof obj === 'function') {
|
|
154
89
|
return '[function object]';
|
|
155
90
|
}
|
|
156
|
-
// Differs from JSON.stringify in that undefined
|
|
91
|
+
// Differs from JSON.stringify in that undefined because undefined and that
|
|
157
92
|
// inf and nan don't become null
|
|
158
93
|
return String(obj);
|
|
159
94
|
}
|
|
@@ -211,19 +146,21 @@ function assertValidProps(component, props) {
|
|
|
211
146
|
!(props.style == null || typeof props.style === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + 'using JSX.%s', getDeclarationErrorAddendum(component)) : invariant(false) : undefined;
|
|
212
147
|
}
|
|
213
148
|
|
|
214
|
-
function enqueuePutListener(
|
|
149
|
+
function enqueuePutListener(inst, registrationName, listener, transaction) {
|
|
215
150
|
if (process.env.NODE_ENV !== 'production') {
|
|
216
151
|
// IE8 has no API for event capturing and the `onScroll` event doesn't
|
|
217
152
|
// bubble.
|
|
218
153
|
process.env.NODE_ENV !== 'production' ? warning(registrationName !== 'onScroll' || isEventSupported('scroll', true), 'This browser doesn\'t support the `onScroll` event') : undefined;
|
|
219
154
|
}
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
155
|
+
var containerInfo = inst._nativeContainerInfo;
|
|
156
|
+
var doc = containerInfo._ownerDocument;
|
|
157
|
+
if (!doc) {
|
|
158
|
+
// Server rendering.
|
|
159
|
+
return;
|
|
224
160
|
}
|
|
161
|
+
listenTo(registrationName, doc);
|
|
225
162
|
transaction.getReactMountReady().enqueue(putListener, {
|
|
226
|
-
|
|
163
|
+
inst: inst,
|
|
227
164
|
registrationName: registrationName,
|
|
228
165
|
listener: listener
|
|
229
166
|
});
|
|
@@ -231,7 +168,7 @@ function enqueuePutListener(id, registrationName, listener, transaction) {
|
|
|
231
168
|
|
|
232
169
|
function putListener() {
|
|
233
170
|
var listenerToPut = this;
|
|
234
|
-
|
|
171
|
+
EventPluginHub.putListener(listenerToPut.inst, listenerToPut.registrationName, listenerToPut.listener);
|
|
235
172
|
}
|
|
236
173
|
|
|
237
174
|
// There are so many media events, it makes sense to just
|
|
@@ -267,7 +204,7 @@ function trapBubbledEventsLocal() {
|
|
|
267
204
|
// If a component renders to null or if another component fatals and causes
|
|
268
205
|
// the state of the tree to be corrupted, `node` here can be null.
|
|
269
206
|
!inst._rootNodeID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Must be mounted to trap events') : invariant(false) : undefined;
|
|
270
|
-
var node =
|
|
207
|
+
var node = getNode(inst);
|
|
271
208
|
!node ? process.env.NODE_ENV !== 'production' ? invariant(false, 'trapBubbledEvent(...): Requires node to be rendered.') : invariant(false) : undefined;
|
|
272
209
|
|
|
273
210
|
switch (inst._tag) {
|
|
@@ -278,7 +215,7 @@ function trapBubbledEventsLocal() {
|
|
|
278
215
|
case 'audio':
|
|
279
216
|
|
|
280
217
|
inst._wrapperState.listeners = [];
|
|
281
|
-
//
|
|
218
|
+
// Create listener for each media event
|
|
282
219
|
for (var event in mediaEvents) {
|
|
283
220
|
if (mediaEvents.hasOwnProperty(event)) {
|
|
284
221
|
inst._wrapperState.listeners.push(ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes[event], mediaEvents[event], node));
|
|
@@ -292,19 +229,20 @@ function trapBubbledEventsLocal() {
|
|
|
292
229
|
case 'form':
|
|
293
230
|
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit', node)];
|
|
294
231
|
break;
|
|
232
|
+
case 'input':
|
|
233
|
+
case 'select':
|
|
234
|
+
case 'textarea':
|
|
235
|
+
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topInvalid, 'invalid', node)];
|
|
236
|
+
break;
|
|
295
237
|
}
|
|
296
238
|
}
|
|
297
239
|
|
|
298
|
-
function mountReadyInputWrapper() {
|
|
299
|
-
ReactDOMInput.mountReadyWrapper(this);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
240
|
function postUpdateSelectWrapper() {
|
|
303
241
|
ReactDOMSelect.postUpdateWrapper(this);
|
|
304
242
|
}
|
|
305
243
|
|
|
306
244
|
// For HTML, certain tags should omit their close tag. We keep a whitelist for
|
|
307
|
-
// those special
|
|
245
|
+
// those special-case tags.
|
|
308
246
|
|
|
309
247
|
var omittedCloseTags = {
|
|
310
248
|
'area': true,
|
|
@@ -353,18 +291,12 @@ function validateDangerousTag(tag) {
|
|
|
353
291
|
}
|
|
354
292
|
}
|
|
355
293
|
|
|
356
|
-
function processChildContextDev(context, inst) {
|
|
357
|
-
// Pass down our tag name to child components for validation purposes
|
|
358
|
-
context = assign({}, context);
|
|
359
|
-
var info = context[validateDOMNesting.ancestorInfoContextKey];
|
|
360
|
-
context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(info, inst._tag, inst);
|
|
361
|
-
return context;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
294
|
function isCustomComponent(tagName, props) {
|
|
365
295
|
return tagName.indexOf('-') >= 0 || props.is != null;
|
|
366
296
|
}
|
|
367
297
|
|
|
298
|
+
var globalIdCounter = 1;
|
|
299
|
+
|
|
368
300
|
/**
|
|
369
301
|
* Creates a new React class that is idempotent and capable of containing other
|
|
370
302
|
* React components. It accepts event listeners and DOM properties that are
|
|
@@ -382,16 +314,20 @@ function isCustomComponent(tagName, props) {
|
|
|
382
314
|
function ReactDOMComponent(tag) {
|
|
383
315
|
validateDangerousTag(tag);
|
|
384
316
|
this._tag = tag.toLowerCase();
|
|
317
|
+
this._namespaceURI = null;
|
|
385
318
|
this._renderedChildren = null;
|
|
386
319
|
this._previousStyle = null;
|
|
387
320
|
this._previousStyleCopy = null;
|
|
321
|
+
this._nativeNode = null;
|
|
322
|
+
this._nativeParent = null;
|
|
388
323
|
this._rootNodeID = null;
|
|
324
|
+
this._domID = null;
|
|
325
|
+
this._nativeContainerInfo = null;
|
|
389
326
|
this._wrapperState = null;
|
|
390
327
|
this._topLevelWrapper = null;
|
|
391
|
-
this.
|
|
328
|
+
this._flags = 0;
|
|
392
329
|
if (process.env.NODE_ENV !== 'production') {
|
|
393
|
-
this.
|
|
394
|
-
this._processedContextDev = null;
|
|
330
|
+
this._ancestorInfo = null;
|
|
395
331
|
}
|
|
396
332
|
}
|
|
397
333
|
|
|
@@ -408,13 +344,17 @@ ReactDOMComponent.Mixin = {
|
|
|
408
344
|
* is not idempotent.
|
|
409
345
|
*
|
|
410
346
|
* @internal
|
|
411
|
-
* @param {string} rootID The root DOM ID for this node.
|
|
412
347
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
348
|
+
* @param {?ReactDOMComponent} the containing DOM component instance
|
|
349
|
+
* @param {?object} info about the native container
|
|
413
350
|
* @param {object} context
|
|
414
351
|
* @return {string} The computed markup.
|
|
415
352
|
*/
|
|
416
|
-
mountComponent: function (
|
|
417
|
-
this._rootNodeID =
|
|
353
|
+
mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
|
|
354
|
+
this._rootNodeID = globalIdCounter++;
|
|
355
|
+
this._domID = nativeContainerInfo._idCounter++;
|
|
356
|
+
this._nativeParent = nativeParent;
|
|
357
|
+
this._nativeContainerInfo = nativeContainerInfo;
|
|
418
358
|
|
|
419
359
|
var props = this._currentElement.props;
|
|
420
360
|
|
|
@@ -430,50 +370,96 @@ ReactDOMComponent.Mixin = {
|
|
|
430
370
|
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
|
|
431
371
|
break;
|
|
432
372
|
case 'button':
|
|
433
|
-
props = ReactDOMButton.getNativeProps(this, props,
|
|
373
|
+
props = ReactDOMButton.getNativeProps(this, props, nativeParent);
|
|
434
374
|
break;
|
|
435
375
|
case 'input':
|
|
436
|
-
ReactDOMInput.mountWrapper(this, props,
|
|
437
|
-
props = ReactDOMInput.getNativeProps(this, props
|
|
376
|
+
ReactDOMInput.mountWrapper(this, props, nativeParent);
|
|
377
|
+
props = ReactDOMInput.getNativeProps(this, props);
|
|
378
|
+
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
|
|
438
379
|
break;
|
|
439
380
|
case 'option':
|
|
440
|
-
ReactDOMOption.mountWrapper(this, props,
|
|
441
|
-
props = ReactDOMOption.getNativeProps(this, props
|
|
381
|
+
ReactDOMOption.mountWrapper(this, props, nativeParent);
|
|
382
|
+
props = ReactDOMOption.getNativeProps(this, props);
|
|
442
383
|
break;
|
|
443
384
|
case 'select':
|
|
444
|
-
ReactDOMSelect.mountWrapper(this, props,
|
|
445
|
-
props = ReactDOMSelect.getNativeProps(this, props
|
|
446
|
-
|
|
385
|
+
ReactDOMSelect.mountWrapper(this, props, nativeParent);
|
|
386
|
+
props = ReactDOMSelect.getNativeProps(this, props);
|
|
387
|
+
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
|
|
447
388
|
break;
|
|
448
389
|
case 'textarea':
|
|
449
|
-
ReactDOMTextarea.mountWrapper(this, props,
|
|
450
|
-
props = ReactDOMTextarea.getNativeProps(this, props
|
|
390
|
+
ReactDOMTextarea.mountWrapper(this, props, nativeParent);
|
|
391
|
+
props = ReactDOMTextarea.getNativeProps(this, props);
|
|
392
|
+
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
|
|
451
393
|
break;
|
|
452
394
|
}
|
|
453
395
|
|
|
454
396
|
assertValidProps(this, props);
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
397
|
+
|
|
398
|
+
// We create tags in the namespace of their parent container, except HTML
|
|
399
|
+
// tags get no namespace.
|
|
400
|
+
var namespaceURI;
|
|
401
|
+
var parentTag;
|
|
402
|
+
if (nativeParent != null) {
|
|
403
|
+
namespaceURI = nativeParent._namespaceURI;
|
|
404
|
+
parentTag = nativeParent._tag;
|
|
405
|
+
} else if (nativeContainerInfo._tag) {
|
|
406
|
+
namespaceURI = nativeContainerInfo._namespaceURI;
|
|
407
|
+
parentTag = nativeContainerInfo._tag;
|
|
408
|
+
}
|
|
409
|
+
if (namespaceURI == null || namespaceURI === DOMNamespaces.svg && parentTag === 'foreignobject') {
|
|
410
|
+
namespaceURI = DOMNamespaces.html;
|
|
411
|
+
}
|
|
412
|
+
if (namespaceURI === DOMNamespaces.html) {
|
|
413
|
+
if (this._tag === 'svg') {
|
|
414
|
+
namespaceURI = DOMNamespaces.svg;
|
|
415
|
+
} else if (this._tag === 'math') {
|
|
416
|
+
namespaceURI = DOMNamespaces.mathml;
|
|
458
417
|
}
|
|
459
418
|
}
|
|
419
|
+
this._namespaceURI = namespaceURI;
|
|
460
420
|
|
|
461
421
|
if (process.env.NODE_ENV !== 'production') {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
422
|
+
var parentInfo;
|
|
423
|
+
if (nativeParent != null) {
|
|
424
|
+
parentInfo = nativeParent._ancestorInfo;
|
|
425
|
+
} else if (nativeContainerInfo._tag) {
|
|
426
|
+
parentInfo = nativeContainerInfo._ancestorInfo;
|
|
427
|
+
}
|
|
428
|
+
if (parentInfo) {
|
|
429
|
+
// parentInfo should always be present except for the top-level
|
|
430
|
+
// component when server rendering
|
|
431
|
+
validateDOMNesting(this._tag, this, parentInfo);
|
|
432
|
+
}
|
|
433
|
+
this._ancestorInfo = validateDOMNesting.updatedAncestorInfo(parentInfo, this._tag, this);
|
|
465
434
|
}
|
|
466
435
|
|
|
467
436
|
var mountImage;
|
|
468
437
|
if (transaction.useCreateElement) {
|
|
469
|
-
var ownerDocument =
|
|
470
|
-
var el
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
438
|
+
var ownerDocument = nativeContainerInfo._ownerDocument;
|
|
439
|
+
var el;
|
|
440
|
+
if (namespaceURI === DOMNamespaces.html) {
|
|
441
|
+
if (this._tag === 'script') {
|
|
442
|
+
// Create the script via .innerHTML so its "parser-inserted" flag is
|
|
443
|
+
// set to true and it does not execute
|
|
444
|
+
var div = ownerDocument.createElement('div');
|
|
445
|
+
var type = this._currentElement.type;
|
|
446
|
+
div.innerHTML = '<' + type + '></' + type + '>';
|
|
447
|
+
el = div.removeChild(div.firstChild);
|
|
448
|
+
} else {
|
|
449
|
+
el = ownerDocument.createElement(this._currentElement.type);
|
|
450
|
+
}
|
|
451
|
+
} else {
|
|
452
|
+
el = ownerDocument.createElementNS(namespaceURI, this._currentElement.type);
|
|
453
|
+
}
|
|
454
|
+
ReactDOMComponentTree.precacheNode(this, el);
|
|
455
|
+
this._flags |= Flags.hasCachedChildNodes;
|
|
456
|
+
if (!this._nativeParent) {
|
|
457
|
+
DOMPropertyOperations.setAttributeForRoot(el);
|
|
458
|
+
}
|
|
459
|
+
this._updateDOMProperties(null, props, transaction);
|
|
460
|
+
var lazyTree = DOMLazyTree(el);
|
|
461
|
+
this._createInitialChildren(transaction, props, context, lazyTree);
|
|
462
|
+
mountImage = lazyTree;
|
|
477
463
|
} else {
|
|
478
464
|
var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props);
|
|
479
465
|
var tagContent = this._createContentMarkup(transaction, props, context);
|
|
@@ -485,10 +471,8 @@ ReactDOMComponent.Mixin = {
|
|
|
485
471
|
}
|
|
486
472
|
|
|
487
473
|
switch (this._tag) {
|
|
488
|
-
case 'input':
|
|
489
|
-
transaction.getReactMountReady().enqueue(mountReadyInputWrapper, this);
|
|
490
|
-
// falls through
|
|
491
474
|
case 'button':
|
|
475
|
+
case 'input':
|
|
492
476
|
case 'select':
|
|
493
477
|
case 'textarea':
|
|
494
478
|
if (props.autoFocus) {
|
|
@@ -526,7 +510,7 @@ ReactDOMComponent.Mixin = {
|
|
|
526
510
|
}
|
|
527
511
|
if (registrationNameModules.hasOwnProperty(propKey)) {
|
|
528
512
|
if (propValue) {
|
|
529
|
-
enqueuePutListener(this
|
|
513
|
+
enqueuePutListener(this, propKey, propValue, transaction);
|
|
530
514
|
}
|
|
531
515
|
} else {
|
|
532
516
|
if (propKey === STYLE) {
|
|
@@ -537,13 +521,15 @@ ReactDOMComponent.Mixin = {
|
|
|
537
521
|
}
|
|
538
522
|
propValue = this._previousStyleCopy = assign({}, props.style);
|
|
539
523
|
}
|
|
540
|
-
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
|
|
524
|
+
propValue = CSSPropertyOperations.createMarkupForStyles(propValue, this);
|
|
541
525
|
}
|
|
542
526
|
var markup = null;
|
|
543
527
|
if (this._tag != null && isCustomComponent(this._tag, props)) {
|
|
544
528
|
if (propKey !== CHILDREN) {
|
|
545
529
|
markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue);
|
|
546
530
|
}
|
|
531
|
+
} else if (this._namespaceURI === DOMNamespaces.svg) {
|
|
532
|
+
markup = DOMPropertyOperations.createMarkupForSVGAttribute(propKey, propValue);
|
|
547
533
|
} else {
|
|
548
534
|
markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
|
|
549
535
|
}
|
|
@@ -559,8 +545,11 @@ ReactDOMComponent.Mixin = {
|
|
|
559
545
|
return ret;
|
|
560
546
|
}
|
|
561
547
|
|
|
562
|
-
|
|
563
|
-
|
|
548
|
+
if (!this._nativeParent) {
|
|
549
|
+
ret += ' ' + DOMPropertyOperations.createMarkupForRoot();
|
|
550
|
+
}
|
|
551
|
+
ret += ' ' + DOMPropertyOperations.createMarkupForID(this._domID);
|
|
552
|
+
return ret;
|
|
564
553
|
},
|
|
565
554
|
|
|
566
555
|
/**
|
|
@@ -609,23 +598,23 @@ ReactDOMComponent.Mixin = {
|
|
|
609
598
|
}
|
|
610
599
|
},
|
|
611
600
|
|
|
612
|
-
_createInitialChildren: function (transaction, props, context,
|
|
601
|
+
_createInitialChildren: function (transaction, props, context, lazyTree) {
|
|
613
602
|
// Intentional use of != to avoid catching zero/false.
|
|
614
603
|
var innerHTML = props.dangerouslySetInnerHTML;
|
|
615
604
|
if (innerHTML != null) {
|
|
616
605
|
if (innerHTML.__html != null) {
|
|
617
|
-
|
|
606
|
+
DOMLazyTree.queueHTML(lazyTree, innerHTML.__html);
|
|
618
607
|
}
|
|
619
608
|
} else {
|
|
620
609
|
var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null;
|
|
621
610
|
var childrenToUse = contentToUse != null ? null : props.children;
|
|
622
611
|
if (contentToUse != null) {
|
|
623
612
|
// TODO: Validate that text is allowed as a child of this node
|
|
624
|
-
|
|
613
|
+
DOMLazyTree.queueText(lazyTree, contentToUse);
|
|
625
614
|
} else if (childrenToUse != null) {
|
|
626
615
|
var mountImages = this.mountChildren(childrenToUse, transaction, context);
|
|
627
616
|
for (var i = 0; i < mountImages.length; i++) {
|
|
628
|
-
|
|
617
|
+
DOMLazyTree.queueChild(lazyTree, mountImages[i]);
|
|
629
618
|
}
|
|
630
619
|
}
|
|
631
620
|
}
|
|
@@ -684,25 +673,10 @@ ReactDOMComponent.Mixin = {
|
|
|
684
673
|
break;
|
|
685
674
|
}
|
|
686
675
|
|
|
687
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
688
|
-
// If the context is reference-equal to the old one, pass down the same
|
|
689
|
-
// processed object so the update bailout in ReactReconciler behaves
|
|
690
|
-
// correctly (and identically in dev and prod). See #5005.
|
|
691
|
-
if (this._unprocessedContextDev !== context) {
|
|
692
|
-
this._unprocessedContextDev = context;
|
|
693
|
-
this._processedContextDev = processChildContextDev(context, this);
|
|
694
|
-
}
|
|
695
|
-
context = this._processedContextDev;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
676
|
assertValidProps(this, nextProps);
|
|
699
|
-
this._updateDOMProperties(lastProps, nextProps, transaction
|
|
677
|
+
this._updateDOMProperties(lastProps, nextProps, transaction);
|
|
700
678
|
this._updateDOMChildren(lastProps, nextProps, transaction, context);
|
|
701
679
|
|
|
702
|
-
if (!canDefineProperty && this._nodeWithLegacyProperties) {
|
|
703
|
-
this._nodeWithLegacyProperties.props = nextProps;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
680
|
if (this._tag === 'select') {
|
|
707
681
|
// <select> value update needs to occur after <option> children
|
|
708
682
|
// reconciliation
|
|
@@ -724,15 +698,14 @@ ReactDOMComponent.Mixin = {
|
|
|
724
698
|
* @private
|
|
725
699
|
* @param {object} lastProps
|
|
726
700
|
* @param {object} nextProps
|
|
727
|
-
* @param {ReactReconcileTransaction} transaction
|
|
728
701
|
* @param {?DOMElement} node
|
|
729
702
|
*/
|
|
730
|
-
_updateDOMProperties: function (lastProps, nextProps, transaction
|
|
703
|
+
_updateDOMProperties: function (lastProps, nextProps, transaction) {
|
|
731
704
|
var propKey;
|
|
732
705
|
var styleName;
|
|
733
706
|
var styleUpdates;
|
|
734
707
|
for (propKey in lastProps) {
|
|
735
|
-
if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey)) {
|
|
708
|
+
if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
|
|
736
709
|
continue;
|
|
737
710
|
}
|
|
738
711
|
if (propKey === STYLE) {
|
|
@@ -749,19 +722,18 @@ ReactDOMComponent.Mixin = {
|
|
|
749
722
|
// Only call deleteListener if there was a listener previously or
|
|
750
723
|
// else willDeleteListener gets called when there wasn't actually a
|
|
751
724
|
// listener (e.g., onClick={null})
|
|
752
|
-
deleteListener(this
|
|
725
|
+
deleteListener(this, propKey);
|
|
753
726
|
}
|
|
727
|
+
} else if (this._namespaceURI === DOMNamespaces.svg) {
|
|
728
|
+
DOMPropertyOperations.deleteValueForSVGAttribute(getNode(this), propKey);
|
|
754
729
|
} else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
|
|
755
|
-
|
|
756
|
-
node = ReactMount.getNode(this._rootNodeID);
|
|
757
|
-
}
|
|
758
|
-
DOMPropertyOperations.deleteValueForProperty(node, propKey);
|
|
730
|
+
DOMPropertyOperations.deleteValueForProperty(getNode(this), propKey);
|
|
759
731
|
}
|
|
760
732
|
}
|
|
761
733
|
for (propKey in nextProps) {
|
|
762
734
|
var nextProp = nextProps[propKey];
|
|
763
|
-
var lastProp = propKey === STYLE ? this._previousStyleCopy : lastProps[propKey];
|
|
764
|
-
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
|
|
735
|
+
var lastProp = propKey === STYLE ? this._previousStyleCopy : lastProps != null ? lastProps[propKey] : undefined;
|
|
736
|
+
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
|
|
765
737
|
continue;
|
|
766
738
|
}
|
|
767
739
|
if (propKey === STYLE) {
|
|
@@ -795,24 +767,21 @@ ReactDOMComponent.Mixin = {
|
|
|
795
767
|
}
|
|
796
768
|
} else if (registrationNameModules.hasOwnProperty(propKey)) {
|
|
797
769
|
if (nextProp) {
|
|
798
|
-
enqueuePutListener(this
|
|
770
|
+
enqueuePutListener(this, propKey, nextProp, transaction);
|
|
799
771
|
} else if (lastProp) {
|
|
800
|
-
deleteListener(this
|
|
772
|
+
deleteListener(this, propKey);
|
|
801
773
|
}
|
|
802
774
|
} else if (isCustomComponent(this._tag, nextProps)) {
|
|
803
|
-
if (!node) {
|
|
804
|
-
node = ReactMount.getNode(this._rootNodeID);
|
|
805
|
-
}
|
|
806
775
|
if (propKey === CHILDREN) {
|
|
807
776
|
nextProp = null;
|
|
808
777
|
}
|
|
809
|
-
DOMPropertyOperations.setValueForAttribute(
|
|
778
|
+
DOMPropertyOperations.setValueForAttribute(getNode(this), propKey, nextProp);
|
|
779
|
+
} else if (this._namespaceURI === DOMNamespaces.svg) {
|
|
780
|
+
DOMPropertyOperations.setValueForSVGAttribute(getNode(this), propKey, nextProp);
|
|
810
781
|
} else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
|
|
811
|
-
|
|
812
|
-
node = ReactMount.getNode(this._rootNodeID);
|
|
813
|
-
}
|
|
782
|
+
var node = getNode(this);
|
|
814
783
|
// If we're updating to null or undefined, we should remove the property
|
|
815
|
-
// from the DOM node instead of
|
|
784
|
+
// from the DOM node instead of inadvertently setting to a string. This
|
|
816
785
|
// brings us in line with the same behavior we have on initial render.
|
|
817
786
|
if (nextProp != null) {
|
|
818
787
|
DOMPropertyOperations.setValueForProperty(node, propKey, nextProp);
|
|
@@ -822,10 +791,7 @@ ReactDOMComponent.Mixin = {
|
|
|
822
791
|
}
|
|
823
792
|
}
|
|
824
793
|
if (styleUpdates) {
|
|
825
|
-
|
|
826
|
-
node = ReactMount.getNode(this._rootNodeID);
|
|
827
|
-
}
|
|
828
|
-
CSSPropertyOperations.setValueForStyles(node, styleUpdates);
|
|
794
|
+
CSSPropertyOperations.setValueForStyles(getNode(this), styleUpdates, this);
|
|
829
795
|
}
|
|
830
796
|
},
|
|
831
797
|
|
|
@@ -872,6 +838,10 @@ ReactDOMComponent.Mixin = {
|
|
|
872
838
|
}
|
|
873
839
|
},
|
|
874
840
|
|
|
841
|
+
getNativeNode: function () {
|
|
842
|
+
return getNode(this);
|
|
843
|
+
},
|
|
844
|
+
|
|
875
845
|
/**
|
|
876
846
|
* Destroys all event registrations for this instance. Does not remove from
|
|
877
847
|
* the DOM. That must be done by the parent.
|
|
@@ -892,9 +862,6 @@ ReactDOMComponent.Mixin = {
|
|
|
892
862
|
}
|
|
893
863
|
}
|
|
894
864
|
break;
|
|
895
|
-
case 'input':
|
|
896
|
-
ReactDOMInput.unmountWrapper(this);
|
|
897
|
-
break;
|
|
898
865
|
case 'html':
|
|
899
866
|
case 'head':
|
|
900
867
|
case 'body':
|
|
@@ -909,52 +876,23 @@ ReactDOMComponent.Mixin = {
|
|
|
909
876
|
}
|
|
910
877
|
|
|
911
878
|
this.unmountChildren();
|
|
912
|
-
|
|
879
|
+
ReactDOMComponentTree.uncacheNode(this);
|
|
880
|
+
EventPluginHub.deleteAllListeners(this);
|
|
913
881
|
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
|
|
914
882
|
this._rootNodeID = null;
|
|
883
|
+
this._domID = null;
|
|
915
884
|
this._wrapperState = null;
|
|
916
|
-
if (this._nodeWithLegacyProperties) {
|
|
917
|
-
var node = this._nodeWithLegacyProperties;
|
|
918
|
-
node._reactInternalComponent = null;
|
|
919
|
-
this._nodeWithLegacyProperties = null;
|
|
920
|
-
}
|
|
921
885
|
},
|
|
922
886
|
|
|
923
887
|
getPublicInstance: function () {
|
|
924
|
-
|
|
925
|
-
var node = ReactMount.getNode(this._rootNodeID);
|
|
926
|
-
|
|
927
|
-
node._reactInternalComponent = this;
|
|
928
|
-
node.getDOMNode = legacyGetDOMNode;
|
|
929
|
-
node.isMounted = legacyIsMounted;
|
|
930
|
-
node.setState = legacySetStateEtc;
|
|
931
|
-
node.replaceState = legacySetStateEtc;
|
|
932
|
-
node.forceUpdate = legacySetStateEtc;
|
|
933
|
-
node.setProps = legacySetProps;
|
|
934
|
-
node.replaceProps = legacyReplaceProps;
|
|
935
|
-
|
|
936
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
937
|
-
if (canDefineProperty) {
|
|
938
|
-
Object.defineProperties(node, legacyPropsDescriptor);
|
|
939
|
-
} else {
|
|
940
|
-
// updateComponent will update this property on subsequent renders
|
|
941
|
-
node.props = this._currentElement.props;
|
|
942
|
-
}
|
|
943
|
-
} else {
|
|
944
|
-
// updateComponent will update this property on subsequent renders
|
|
945
|
-
node.props = this._currentElement.props;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
this._nodeWithLegacyProperties = node;
|
|
949
|
-
}
|
|
950
|
-
return this._nodeWithLegacyProperties;
|
|
888
|
+
return getNode(this);
|
|
951
889
|
}
|
|
952
890
|
|
|
953
891
|
};
|
|
954
892
|
|
|
955
|
-
ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', {
|
|
893
|
+
ReactPerf.measureMethods(ReactDOMComponent.Mixin, 'ReactDOMComponent', {
|
|
956
894
|
mountComponent: 'mountComponent',
|
|
957
|
-
|
|
895
|
+
receiveComponent: 'receiveComponent'
|
|
958
896
|
});
|
|
959
897
|
|
|
960
898
|
assign(ReactDOMComponent.prototype, ReactDOMComponent.Mixin, ReactMultiChild.Mixin);
|