react 0.12.2 → 0.13.0-beta.2
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/dist/JSXTransformer.js +986 -511
- package/dist/react-with-addons.js +6076 -4560
- package/dist/react-with-addons.min.js +6 -7
- package/dist/react.js +5386 -4170
- package/dist/react.min.js +6 -7
- package/lib/AutoFocusMixin.js +2 -2
- package/lib/BeforeInputEventPlugin.js +388 -115
- package/lib/CSSCore.js +1 -1
- package/lib/CSSProperty.js +2 -2
- package/lib/CSSPropertyOperations.js +58 -11
- package/lib/CallbackQueue.js +3 -3
- package/lib/ChangeEventPlugin.js +4 -4
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +10 -47
- package/lib/DOMProperty.js +2 -2
- package/lib/DOMPropertyOperations.js +11 -16
- package/lib/Danger.js +8 -7
- package/lib/DefaultEventPluginOrder.js +3 -4
- package/lib/EnterLeaveEventPlugin.js +2 -2
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +1 -1
- package/lib/EventPluginHub.js +10 -8
- package/lib/EventPluginRegistry.js +2 -2
- package/lib/EventPluginUtils.js +4 -4
- package/lib/EventPropagators.js +2 -2
- package/lib/ExecutionEnvironment.js +3 -4
- package/lib/FallbackCompositionState.js +89 -0
- package/lib/HTMLDOMPropertyConfig.js +23 -10
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +4 -4
- package/lib/LocalEventTrapMixin.js +10 -3
- package/lib/MobileSafariClickEventPlugin.js +2 -2
- package/lib/Object.assign.js +4 -2
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +19 -58
- package/lib/ReactBrowserComponentMixin.js +4 -14
- package/lib/ReactBrowserEventEmitter.js +6 -8
- package/lib/ReactCSSTransitionGroup.js +5 -2
- package/lib/ReactCSSTransitionGroupChild.js +20 -7
- package/lib/ReactChildReconciler.js +125 -0
- package/lib/ReactChildren.js +13 -10
- package/lib/ReactClass.js +918 -0
- package/lib/ReactComponent.js +98 -406
- package/lib/ReactComponentBrowserEnvironment.js +11 -84
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +574 -1140
- package/lib/ReactContext.js +17 -3
- package/lib/ReactCurrentOwner.js +2 -2
- package/lib/ReactDOM.js +4 -9
- package/lib/ReactDOMButton.js +6 -7
- package/lib/ReactDOMComponent.js +123 -105
- package/lib/ReactDOMForm.js +6 -7
- package/lib/ReactDOMIDOperations.js +59 -77
- package/lib/ReactDOMIframe.js +43 -0
- package/lib/ReactDOMImg.js +5 -7
- package/lib/ReactDOMInput.js +6 -7
- package/lib/ReactDOMOption.js +6 -7
- package/lib/ReactDOMSelect.js +58 -66
- package/lib/ReactDOMSelection.js +7 -3
- package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -37
- package/lib/ReactDOMTextarea.js +6 -7
- package/lib/ReactDefaultBatchingStrategy.js +5 -5
- package/lib/ReactDefaultInjection.js +39 -9
- package/lib/ReactDefaultPerf.js +17 -8
- package/lib/ReactDefaultPerfAnalysis.js +2 -2
- package/lib/ReactElement.js +23 -15
- package/lib/ReactElementValidator.js +206 -89
- package/lib/ReactEmptyComponent.js +33 -15
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +2 -2
- package/lib/ReactEventListener.js +4 -5
- package/lib/ReactFragment.js +172 -0
- package/lib/ReactInjection.js +8 -6
- package/lib/ReactInputSelection.js +4 -5
- package/lib/ReactInstanceHandles.js +4 -3
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactLifeCycle.js +35 -0
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +2 -2
- package/lib/ReactMount.js +264 -71
- package/lib/ReactMultiChild.js +50 -48
- package/lib/ReactMultiChildUpdateTypes.js +2 -2
- package/lib/ReactNativeComponent.js +59 -25
- package/lib/ReactOwner.js +5 -49
- package/lib/ReactPerf.js +22 -2
- package/lib/ReactPropTransferer.js +3 -58
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +2 -2
- package/lib/ReactPropTypes.js +17 -25
- package/lib/ReactPutListenerQueue.js +2 -2
- package/lib/ReactReconcileTransaction.js +2 -2
- package/lib/ReactReconciler.js +121 -0
- package/lib/ReactRef.js +69 -0
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +6 -4
- package/lib/ReactServerRenderingTransaction.js +2 -2
- package/lib/ReactStateSetters.js +2 -2
- package/lib/ReactTestUtils.js +113 -27
- package/lib/ReactTransitionChildMapping.js +8 -4
- package/lib/ReactTransitionEvents.js +2 -2
- package/lib/ReactTransitionGroup.js +53 -12
- package/lib/ReactUpdateQueue.js +295 -0
- package/lib/ReactUpdates.js +54 -62
- package/lib/ReactWithAddons.js +4 -2
- package/lib/SVGDOMPropertyConfig.js +2 -2
- package/lib/SelectEventPlugin.js +4 -4
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +4 -4
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -2
- package/lib/SyntheticEvent.js +12 -4
- package/lib/SyntheticFocusEvent.js +2 -2
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -2
- package/lib/SyntheticMouseEvent.js +3 -5
- package/lib/SyntheticTouchEvent.js +2 -2
- package/lib/SyntheticUIEvent.js +2 -2
- package/lib/SyntheticWheelEvent.js +2 -2
- package/lib/Transaction.js +4 -4
- package/lib/ViewportMetrics.js +3 -6
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +2 -2
- package/lib/camelize.js +1 -1
- package/lib/camelizeStyleName.js +1 -1
- package/lib/cloneWithProps.js +4 -4
- package/lib/containsNode.js +1 -1
- package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
- package/lib/createFullPageComponent.js +4 -4
- package/lib/createNodesFromMarkup.js +4 -4
- package/lib/cx.js +1 -1
- package/lib/dangerousStyleValue.js +2 -2
- package/lib/emptyFunction.js +1 -1
- package/lib/emptyObject.js +1 -1
- package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +10 -11
- package/lib/findDOMNode.js +51 -0
- package/lib/flattenChildren.js +12 -23
- package/lib/focusNode.js +1 -1
- package/lib/forEachAccumulated.js +2 -2
- package/lib/getActiveElement.js +1 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +2 -2
- package/lib/getEventModifierState.js +2 -2
- package/lib/getEventTarget.js +2 -2
- package/lib/getIteratorFn.js +42 -0
- package/lib/getMarkupWrap.js +1 -1
- package/lib/getNodeForCharacterOffset.js +3 -3
- package/lib/getReactRootElementInContainer.js +2 -2
- package/lib/getTextContentAccessor.js +2 -2
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +1 -1
- package/lib/hyphenateStyleName.js +1 -1
- package/lib/instantiateReactComponent.js +90 -68
- package/lib/invariant.js +1 -1
- package/lib/isEventSupported.js +2 -2
- package/lib/isNode.js +4 -5
- package/lib/isTextInputElement.js +3 -4
- package/lib/isTextNode.js +1 -1
- package/lib/joinClasses.js +2 -2
- package/lib/keyMirror.js +2 -2
- package/lib/keyOf.js +1 -1
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +5 -6
- package/lib/onlyChild.js +2 -2
- package/lib/performance.js +1 -1
- package/lib/performanceNow.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +26 -0
- package/lib/setInnerHTML.js +13 -2
- package/lib/setTextContent.js +40 -0
- package/lib/shallowEqual.js +2 -2
- package/lib/shouldUpdateReactComponent.js +71 -7
- package/lib/toArray.js +2 -2
- package/lib/traverseAllChildren.js +114 -56
- package/lib/update.js +2 -2
- package/lib/warning.js +20 -2
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -243
- package/lib/copyProperties.js +0 -54
- package/lib/deprecated.js +0 -47
- package/lib/merge.js +0 -34
- package/lib/mergeInto.js +0 -24
- package/lib/monitorCodeUse.js +0 -30
package/lib/ReactContext.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -9,9 +9,13 @@
|
|
|
9
9
|
* @providesModule ReactContext
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var assign = require("./Object.assign");
|
|
15
|
+
var emptyObject = require("./emptyObject");
|
|
16
|
+
var warning = require("./warning");
|
|
17
|
+
|
|
18
|
+
var didWarn = false;
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* Keeps track of the current context.
|
|
@@ -25,7 +29,7 @@ var ReactContext = {
|
|
|
25
29
|
* @internal
|
|
26
30
|
* @type {object}
|
|
27
31
|
*/
|
|
28
|
-
current:
|
|
32
|
+
current: emptyObject,
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
35
|
* Temporarily extends the current context while executing scopedCallback.
|
|
@@ -44,6 +48,16 @@ var ReactContext = {
|
|
|
44
48
|
* @return {ReactComponent|array<ReactComponent>}
|
|
45
49
|
*/
|
|
46
50
|
withContext: function(newContext, scopedCallback) {
|
|
51
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
52
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
53
|
+
didWarn,
|
|
54
|
+
'withContext is deprecated and will be removed in a future version. ' +
|
|
55
|
+
'Use a wrapper component with getChildContext instead.'
|
|
56
|
+
) : null);
|
|
57
|
+
|
|
58
|
+
didWarn = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
var result;
|
|
48
62
|
var previousContext = ReactContext.current;
|
|
49
63
|
ReactContext.current = assign({}, previousContext, newContext);
|
package/lib/ReactCurrentOwner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @providesModule ReactCurrentOwner
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Keeps track of the current owner.
|
package/lib/ReactDOM.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
* @typechecks static-only
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
'use strict';
|
|
14
14
|
|
|
15
15
|
var ReactElement = require("./ReactElement");
|
|
16
16
|
var ReactElementValidator = require("./ReactElementValidator");
|
|
17
|
-
var ReactLegacyElement = require("./ReactLegacyElement");
|
|
18
17
|
|
|
19
18
|
var mapObject = require("./mapObject");
|
|
20
19
|
|
|
@@ -26,13 +25,9 @@ var mapObject = require("./mapObject");
|
|
|
26
25
|
*/
|
|
27
26
|
function createDOMFactory(tag) {
|
|
28
27
|
if ("production" !== process.env.NODE_ENV) {
|
|
29
|
-
return
|
|
30
|
-
ReactElementValidator.createFactory(tag)
|
|
31
|
-
);
|
|
28
|
+
return ReactElementValidator.createFactory(tag);
|
|
32
29
|
}
|
|
33
|
-
return
|
|
34
|
-
ReactElement.createFactory(tag)
|
|
35
|
-
);
|
|
30
|
+
return ReactElement.createFactory(tag);
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
/**
|
package/lib/ReactDOMButton.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -9,18 +9,16 @@
|
|
|
9
9
|
* @providesModule ReactDOMButton
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
15
15
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
16
|
-
var
|
|
16
|
+
var ReactClass = require("./ReactClass");
|
|
17
17
|
var ReactElement = require("./ReactElement");
|
|
18
|
-
var ReactDOM = require("./ReactDOM");
|
|
19
18
|
|
|
20
19
|
var keyMirror = require("./keyMirror");
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
var button = ReactElement.createFactory(ReactDOM.button.type);
|
|
21
|
+
var button = ReactElement.createFactory('button');
|
|
24
22
|
|
|
25
23
|
var mouseListenerNames = keyMirror({
|
|
26
24
|
onClick: true,
|
|
@@ -39,8 +37,9 @@ var mouseListenerNames = keyMirror({
|
|
|
39
37
|
* Implements a <button> native component that does not receive mouse events
|
|
40
38
|
* when `disabled` is set.
|
|
41
39
|
*/
|
|
42
|
-
var ReactDOMButton =
|
|
40
|
+
var ReactDOMButton = ReactClass.createClass({
|
|
43
41
|
displayName: 'ReactDOMButton',
|
|
42
|
+
tagName: 'BUTTON',
|
|
44
43
|
|
|
45
44
|
mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
|
|
46
45
|
|
package/lib/ReactDOMComponent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -10,24 +10,26 @@
|
|
|
10
10
|
* @typechecks static-only
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/* global hasOwnProperty:true */
|
|
14
|
+
|
|
15
|
+
'use strict';
|
|
14
16
|
|
|
15
17
|
var CSSPropertyOperations = require("./CSSPropertyOperations");
|
|
16
18
|
var DOMProperty = require("./DOMProperty");
|
|
17
19
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
18
|
-
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
19
|
-
var ReactComponent = require("./ReactComponent");
|
|
20
20
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
21
|
+
var ReactComponentBrowserEnvironment =
|
|
22
|
+
require("./ReactComponentBrowserEnvironment");
|
|
21
23
|
var ReactMount = require("./ReactMount");
|
|
22
24
|
var ReactMultiChild = require("./ReactMultiChild");
|
|
23
25
|
var ReactPerf = require("./ReactPerf");
|
|
24
26
|
|
|
25
27
|
var assign = require("./Object.assign");
|
|
26
|
-
var
|
|
28
|
+
var escapeTextContentForBrowser = require("./escapeTextContentForBrowser");
|
|
27
29
|
var invariant = require("./invariant");
|
|
28
30
|
var isEventSupported = require("./isEventSupported");
|
|
29
31
|
var keyOf = require("./keyOf");
|
|
30
|
-
var
|
|
32
|
+
var warning = require("./warning");
|
|
31
33
|
|
|
32
34
|
var deleteListener = ReactBrowserEventEmitter.deleteListener;
|
|
33
35
|
var listenTo = ReactBrowserEventEmitter.listenTo;
|
|
@@ -40,6 +42,11 @@ var STYLE = keyOf({style: null});
|
|
|
40
42
|
|
|
41
43
|
var ELEMENT_NODE_TYPE = 1;
|
|
42
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Optionally injectable operations for mutating the DOM
|
|
47
|
+
*/
|
|
48
|
+
var BackendIDOperations = null;
|
|
49
|
+
|
|
43
50
|
/**
|
|
44
51
|
* @param {?object} props
|
|
45
52
|
*/
|
|
@@ -48,24 +55,37 @@ function assertValidProps(props) {
|
|
|
48
55
|
return;
|
|
49
56
|
}
|
|
50
57
|
// Note the use of `==` which checks for null or undefined.
|
|
51
|
-
(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
if (props.dangerouslySetInnerHTML != null) {
|
|
59
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
60
|
+
props.children == null,
|
|
61
|
+
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
|
|
62
|
+
) : invariant(props.children == null));
|
|
63
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
64
|
+
props.dangerouslySetInnerHTML.__html != null,
|
|
65
|
+
'`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
|
|
66
|
+
'Please visit http://fb.me/react-invariant-dangerously-set-inner-html ' +
|
|
67
|
+
'for more information.'
|
|
68
|
+
) : invariant(props.dangerouslySetInnerHTML.__html != null));
|
|
69
|
+
}
|
|
55
70
|
if ("production" !== process.env.NODE_ENV) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
72
|
+
props.innerHTML == null,
|
|
73
|
+
'Directly setting property `innerHTML` is not permitted. ' +
|
|
74
|
+
'For more information, lookup documentation on `dangerouslySetInnerHTML`.'
|
|
75
|
+
) : null);
|
|
76
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
77
|
+
!props.contentEditable || props.children == null,
|
|
78
|
+
'A component is `contentEditable` and contains `children` managed by ' +
|
|
79
|
+
'React. It is now your responsibility to guarantee that none of ' +
|
|
80
|
+
'those nodes are unexpectedly modified or duplicated. This is ' +
|
|
81
|
+
'probably not intentional.'
|
|
82
|
+
) : null);
|
|
64
83
|
}
|
|
65
84
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
66
85
|
props.style == null || typeof props.style === 'object',
|
|
67
86
|
'The `style` prop expects a mapping from style properties to values, ' +
|
|
68
|
-
'not a string.'
|
|
87
|
+
'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' +
|
|
88
|
+
'using JSX.'
|
|
69
89
|
) : invariant(props.style == null || typeof props.style === 'object'));
|
|
70
90
|
}
|
|
71
91
|
|
|
@@ -73,11 +93,10 @@ function putListener(id, registrationName, listener, transaction) {
|
|
|
73
93
|
if ("production" !== process.env.NODE_ENV) {
|
|
74
94
|
// IE8 has no API for event capturing and the `onScroll` event doesn't
|
|
75
95
|
// bubble.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
96
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
97
|
+
registrationName !== 'onScroll' || isEventSupported('scroll', true),
|
|
98
|
+
'This browser doesn\'t support the `onScroll` event'
|
|
99
|
+
) : null);
|
|
81
100
|
}
|
|
82
101
|
var container = ReactMount.findReactContainerForID(id);
|
|
83
102
|
if (container) {
|
|
@@ -142,19 +161,24 @@ function validateDangerousTag(tag) {
|
|
|
142
161
|
* object mapping of style properties to values.
|
|
143
162
|
*
|
|
144
163
|
* @constructor ReactDOMComponent
|
|
145
|
-
* @extends ReactComponent
|
|
146
164
|
* @extends ReactMultiChild
|
|
147
165
|
*/
|
|
148
166
|
function ReactDOMComponent(tag) {
|
|
149
167
|
validateDangerousTag(tag);
|
|
150
168
|
this._tag = tag;
|
|
151
|
-
this.
|
|
169
|
+
this._renderedChildren = null;
|
|
170
|
+
this._previousStyleCopy = null;
|
|
171
|
+
this._rootNodeID = null;
|
|
152
172
|
}
|
|
153
173
|
|
|
154
174
|
ReactDOMComponent.displayName = 'ReactDOMComponent';
|
|
155
175
|
|
|
156
176
|
ReactDOMComponent.Mixin = {
|
|
157
177
|
|
|
178
|
+
construct: function(element) {
|
|
179
|
+
this._currentElement = element;
|
|
180
|
+
},
|
|
181
|
+
|
|
158
182
|
/**
|
|
159
183
|
* Generates root tag markup then recurses. This method has side effects and
|
|
160
184
|
* is not idempotent.
|
|
@@ -162,28 +186,18 @@ ReactDOMComponent.Mixin = {
|
|
|
162
186
|
* @internal
|
|
163
187
|
* @param {string} rootID The root DOM ID for this node.
|
|
164
188
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
165
|
-
* @param {number} mountDepth number of components in the owner hierarchy
|
|
166
189
|
* @return {string} The computed markup.
|
|
167
190
|
*/
|
|
168
|
-
mountComponent:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
assertValidProps(this.props);
|
|
179
|
-
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
|
|
180
|
-
return (
|
|
181
|
-
this._createOpenTagMarkupAndPutListeners(transaction) +
|
|
182
|
-
this._createContentMarkup(transaction) +
|
|
183
|
-
closeTag
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
),
|
|
191
|
+
mountComponent: function(rootID, transaction, context) {
|
|
192
|
+
this._rootNodeID = rootID;
|
|
193
|
+
assertValidProps(this._currentElement.props);
|
|
194
|
+
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
|
|
195
|
+
return (
|
|
196
|
+
this._createOpenTagMarkupAndPutListeners(transaction) +
|
|
197
|
+
this._createContentMarkup(transaction, context) +
|
|
198
|
+
closeTag
|
|
199
|
+
);
|
|
200
|
+
},
|
|
187
201
|
|
|
188
202
|
/**
|
|
189
203
|
* Creates markup for the open tag and all attributes.
|
|
@@ -198,7 +212,7 @@ ReactDOMComponent.Mixin = {
|
|
|
198
212
|
* @return {string} Markup of opening tag.
|
|
199
213
|
*/
|
|
200
214
|
_createOpenTagMarkupAndPutListeners: function(transaction) {
|
|
201
|
-
var props = this.props;
|
|
215
|
+
var props = this._currentElement.props;
|
|
202
216
|
var ret = '<' + this._tag;
|
|
203
217
|
|
|
204
218
|
for (var propKey in props) {
|
|
@@ -214,7 +228,7 @@ ReactDOMComponent.Mixin = {
|
|
|
214
228
|
} else {
|
|
215
229
|
if (propKey === STYLE) {
|
|
216
230
|
if (propValue) {
|
|
217
|
-
propValue =
|
|
231
|
+
propValue = this._previousStyleCopy = assign({}, props.style);
|
|
218
232
|
}
|
|
219
233
|
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
|
|
220
234
|
}
|
|
@@ -241,50 +255,50 @@ ReactDOMComponent.Mixin = {
|
|
|
241
255
|
*
|
|
242
256
|
* @private
|
|
243
257
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
258
|
+
* @param {object} context
|
|
244
259
|
* @return {string} Content markup.
|
|
245
260
|
*/
|
|
246
|
-
_createContentMarkup: function(transaction) {
|
|
261
|
+
_createContentMarkup: function(transaction, context) {
|
|
262
|
+
var prefix = '';
|
|
263
|
+
if (this._tag === 'listing' ||
|
|
264
|
+
this._tag === 'pre' ||
|
|
265
|
+
this._tag === 'textarea') {
|
|
266
|
+
// Add an initial newline because browsers ignore the first newline in
|
|
267
|
+
// a <listing>, <pre>, or <textarea> as an "authoring convenience" -- see
|
|
268
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody.
|
|
269
|
+
prefix = '\n';
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
var props = this._currentElement.props;
|
|
273
|
+
|
|
247
274
|
// Intentional use of != to avoid catching zero/false.
|
|
248
|
-
var innerHTML =
|
|
275
|
+
var innerHTML = props.dangerouslySetInnerHTML;
|
|
249
276
|
if (innerHTML != null) {
|
|
250
277
|
if (innerHTML.__html != null) {
|
|
251
|
-
return innerHTML.__html;
|
|
278
|
+
return prefix + innerHTML.__html;
|
|
252
279
|
}
|
|
253
280
|
} else {
|
|
254
281
|
var contentToUse =
|
|
255
|
-
CONTENT_TYPES[typeof
|
|
256
|
-
var childrenToUse = contentToUse != null ? null :
|
|
282
|
+
CONTENT_TYPES[typeof props.children] ? props.children : null;
|
|
283
|
+
var childrenToUse = contentToUse != null ? null : props.children;
|
|
257
284
|
if (contentToUse != null) {
|
|
258
|
-
return
|
|
285
|
+
return prefix + escapeTextContentForBrowser(contentToUse);
|
|
259
286
|
} else if (childrenToUse != null) {
|
|
260
287
|
var mountImages = this.mountChildren(
|
|
261
288
|
childrenToUse,
|
|
262
|
-
transaction
|
|
289
|
+
transaction,
|
|
290
|
+
context
|
|
263
291
|
);
|
|
264
|
-
return mountImages.join('');
|
|
292
|
+
return prefix + mountImages.join('');
|
|
265
293
|
}
|
|
266
294
|
}
|
|
267
|
-
return
|
|
295
|
+
return prefix;
|
|
268
296
|
},
|
|
269
297
|
|
|
270
|
-
receiveComponent: function(nextElement, transaction) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// we can do a cheap identity compare here to determine if this is a
|
|
275
|
-
// superfluous reconcile. It's possible for state to be mutable but such
|
|
276
|
-
// change should trigger an update of the owner which would recreate
|
|
277
|
-
// the element. We explicitly check for the existence of an owner since
|
|
278
|
-
// it's possible for a element created outside a composite to be
|
|
279
|
-
// deeply mutated and reused.
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
ReactComponent.Mixin.receiveComponent.call(
|
|
284
|
-
this,
|
|
285
|
-
nextElement,
|
|
286
|
-
transaction
|
|
287
|
-
);
|
|
298
|
+
receiveComponent: function(nextElement, transaction, context) {
|
|
299
|
+
var prevElement = this._currentElement;
|
|
300
|
+
this._currentElement = nextElement;
|
|
301
|
+
this.updateComponent(transaction, prevElement, nextElement, context);
|
|
288
302
|
},
|
|
289
303
|
|
|
290
304
|
/**
|
|
@@ -293,23 +307,15 @@ ReactDOMComponent.Mixin = {
|
|
|
293
307
|
*
|
|
294
308
|
* @param {ReactReconcileTransaction} transaction
|
|
295
309
|
* @param {ReactElement} prevElement
|
|
310
|
+
* @param {ReactElement} nextElement
|
|
296
311
|
* @internal
|
|
297
312
|
* @overridable
|
|
298
313
|
*/
|
|
299
|
-
updateComponent:
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
ReactComponent.Mixin.updateComponent.call(
|
|
305
|
-
this,
|
|
306
|
-
transaction,
|
|
307
|
-
prevElement
|
|
308
|
-
);
|
|
309
|
-
this._updateDOMProperties(prevElement.props, transaction);
|
|
310
|
-
this._updateDOMChildren(prevElement.props, transaction);
|
|
311
|
-
}
|
|
312
|
-
),
|
|
314
|
+
updateComponent: function(transaction, prevElement, nextElement, context) {
|
|
315
|
+
assertValidProps(this._currentElement.props);
|
|
316
|
+
this._updateDOMProperties(prevElement.props, transaction);
|
|
317
|
+
this._updateDOMChildren(prevElement.props, transaction, context);
|
|
318
|
+
},
|
|
313
319
|
|
|
314
320
|
/**
|
|
315
321
|
* Reconciles the properties by detecting differences in property values and
|
|
@@ -327,7 +333,7 @@ ReactDOMComponent.Mixin = {
|
|
|
327
333
|
* @param {ReactReconcileTransaction} transaction
|
|
328
334
|
*/
|
|
329
335
|
_updateDOMProperties: function(lastProps, transaction) {
|
|
330
|
-
var nextProps = this.props;
|
|
336
|
+
var nextProps = this._currentElement.props;
|
|
331
337
|
var propKey;
|
|
332
338
|
var styleName;
|
|
333
339
|
var styleUpdates;
|
|
@@ -337,7 +343,7 @@ ReactDOMComponent.Mixin = {
|
|
|
337
343
|
continue;
|
|
338
344
|
}
|
|
339
345
|
if (propKey === STYLE) {
|
|
340
|
-
var lastStyle =
|
|
346
|
+
var lastStyle = this._previousStyleCopy;
|
|
341
347
|
for (styleName in lastStyle) {
|
|
342
348
|
if (lastStyle.hasOwnProperty(styleName)) {
|
|
343
349
|
styleUpdates = styleUpdates || {};
|
|
@@ -349,7 +355,7 @@ ReactDOMComponent.Mixin = {
|
|
|
349
355
|
} else if (
|
|
350
356
|
DOMProperty.isStandardName[propKey] ||
|
|
351
357
|
DOMProperty.isCustomAttribute(propKey)) {
|
|
352
|
-
|
|
358
|
+
BackendIDOperations.deletePropertyByID(
|
|
353
359
|
this._rootNodeID,
|
|
354
360
|
propKey
|
|
355
361
|
);
|
|
@@ -357,13 +363,15 @@ ReactDOMComponent.Mixin = {
|
|
|
357
363
|
}
|
|
358
364
|
for (propKey in nextProps) {
|
|
359
365
|
var nextProp = nextProps[propKey];
|
|
360
|
-
var lastProp =
|
|
366
|
+
var lastProp = propKey === STYLE ?
|
|
367
|
+
this._previousStyleCopy :
|
|
368
|
+
lastProps[propKey];
|
|
361
369
|
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
|
|
362
370
|
continue;
|
|
363
371
|
}
|
|
364
372
|
if (propKey === STYLE) {
|
|
365
373
|
if (nextProp) {
|
|
366
|
-
nextProp =
|
|
374
|
+
nextProp = this._previousStyleCopy = assign({}, nextProp);
|
|
367
375
|
}
|
|
368
376
|
if (lastProp) {
|
|
369
377
|
// Unset styles on `lastProp` but not on `nextProp`.
|
|
@@ -391,7 +399,7 @@ ReactDOMComponent.Mixin = {
|
|
|
391
399
|
} else if (
|
|
392
400
|
DOMProperty.isStandardName[propKey] ||
|
|
393
401
|
DOMProperty.isCustomAttribute(propKey)) {
|
|
394
|
-
|
|
402
|
+
BackendIDOperations.updatePropertyByID(
|
|
395
403
|
this._rootNodeID,
|
|
396
404
|
propKey,
|
|
397
405
|
nextProp
|
|
@@ -399,7 +407,7 @@ ReactDOMComponent.Mixin = {
|
|
|
399
407
|
}
|
|
400
408
|
}
|
|
401
409
|
if (styleUpdates) {
|
|
402
|
-
|
|
410
|
+
BackendIDOperations.updateStylesByID(
|
|
403
411
|
this._rootNodeID,
|
|
404
412
|
styleUpdates
|
|
405
413
|
);
|
|
@@ -413,8 +421,8 @@ ReactDOMComponent.Mixin = {
|
|
|
413
421
|
* @param {object} lastProps
|
|
414
422
|
* @param {ReactReconcileTransaction} transaction
|
|
415
423
|
*/
|
|
416
|
-
_updateDOMChildren: function(lastProps, transaction) {
|
|
417
|
-
var nextProps = this.props;
|
|
424
|
+
_updateDOMChildren: function(lastProps, transaction, context) {
|
|
425
|
+
var nextProps = this._currentElement.props;
|
|
418
426
|
|
|
419
427
|
var lastContent =
|
|
420
428
|
CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
|
|
@@ -437,7 +445,7 @@ ReactDOMComponent.Mixin = {
|
|
|
437
445
|
var lastHasContentOrHtml = lastContent != null || lastHtml != null;
|
|
438
446
|
var nextHasContentOrHtml = nextContent != null || nextHtml != null;
|
|
439
447
|
if (lastChildren != null && nextChildren == null) {
|
|
440
|
-
this.updateChildren(null, transaction);
|
|
448
|
+
this.updateChildren(null, transaction, context);
|
|
441
449
|
} else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
|
|
442
450
|
this.updateTextContent('');
|
|
443
451
|
}
|
|
@@ -448,13 +456,13 @@ ReactDOMComponent.Mixin = {
|
|
|
448
456
|
}
|
|
449
457
|
} else if (nextHtml != null) {
|
|
450
458
|
if (lastHtml !== nextHtml) {
|
|
451
|
-
|
|
459
|
+
BackendIDOperations.updateInnerHTMLByID(
|
|
452
460
|
this._rootNodeID,
|
|
453
461
|
nextHtml
|
|
454
462
|
);
|
|
455
463
|
}
|
|
456
464
|
} else if (nextChildren != null) {
|
|
457
|
-
this.updateChildren(nextChildren, transaction);
|
|
465
|
+
this.updateChildren(nextChildren, transaction, context);
|
|
458
466
|
}
|
|
459
467
|
},
|
|
460
468
|
|
|
@@ -467,17 +475,27 @@ ReactDOMComponent.Mixin = {
|
|
|
467
475
|
unmountComponent: function() {
|
|
468
476
|
this.unmountChildren();
|
|
469
477
|
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
|
|
470
|
-
|
|
478
|
+
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
|
|
479
|
+
this._rootNodeID = null;
|
|
471
480
|
}
|
|
472
481
|
|
|
473
482
|
};
|
|
474
483
|
|
|
484
|
+
ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', {
|
|
485
|
+
mountComponent: 'mountComponent',
|
|
486
|
+
updateComponent: 'updateComponent'
|
|
487
|
+
});
|
|
488
|
+
|
|
475
489
|
assign(
|
|
476
490
|
ReactDOMComponent.prototype,
|
|
477
|
-
ReactComponent.Mixin,
|
|
478
491
|
ReactDOMComponent.Mixin,
|
|
479
|
-
ReactMultiChild.Mixin
|
|
480
|
-
ReactBrowserComponentMixin
|
|
492
|
+
ReactMultiChild.Mixin
|
|
481
493
|
);
|
|
482
494
|
|
|
495
|
+
ReactDOMComponent.injection = {
|
|
496
|
+
injectIDOperations: function(IDOperations) {
|
|
497
|
+
ReactDOMComponent.BackendIDOperations = BackendIDOperations = IDOperations;
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
|
|
483
501
|
module.exports = ReactDOMComponent;
|