react 0.14.8 → 15.0.0-rc.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/addons.js +2 -0
- package/dist/react-with-addons.js +4203 -4148
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4159 -3850
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +4 -1
- package/lib/CSSPropertyOperations.js +24 -10
- package/lib/CallbackQueue.js +13 -2
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +93 -60
- package/lib/DOMLazyTree.js +96 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +87 -53
- package/lib/Danger.js +13 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +22 -66
- package/lib/EventPluginRegistry.js +30 -9
- package/lib/EventPluginUtils.js +61 -36
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +1 -2
- package/lib/HTMLDOMPropertyConfig.js +69 -90
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +5 -6
- package/lib/MetaMatchers.js +2 -2
- package/lib/Object.assign.js +1 -1
- package/lib/OrderedMap.js +14 -14
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +1 -13
- package/lib/ReactBrowserEventEmitter.js +16 -24
- package/lib/ReactCSSTransitionGroup.js +1 -2
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +37 -86
- package/lib/ReactComponent.js +7 -8
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +160 -69
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +188 -244
- 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 +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +71 -22
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +11 -10
- package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +61 -0
- package/lib/ReactDOMSelect.js +40 -17
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +84 -43
- package/lib/ReactDOMTextarea.js +36 -9
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +59 -19
- package/lib/ReactDefaultPerfAnalysis.js +17 -9
- package/lib/ReactElement.js +60 -21
- package/lib/ReactElementValidator.js +8 -8
- package/lib/ReactEmptyComponent.js +8 -33
- 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 +6 -6
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -12
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactIsomorphic.js +1 -1
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +87 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +3 -3
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +27 -3
- package/lib/ReactReconcileTransaction.js +17 -6
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +17 -35
- package/lib/ReactServerRenderingTransaction.js +8 -26
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +33 -24
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +1 -1
- package/lib/ReactUpdateQueue.js +6 -65
- package/lib/ReactUpdates.js +26 -9
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -14
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +1 -2
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +25 -66
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +57 -17
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +97 -17
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +2 -2
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +4 -2
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +2 -2
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +9 -11
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +2 -2
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +2 -2
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +5 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +8 -8
- package/lib/update.js +12 -12
- package/lib/validateDOMNesting.js +15 -11
- 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/ReactDOMServer.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,19 +7,18 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactDOMTextComponent
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
15
14
|
var DOMChildrenOperations = require('./DOMChildrenOperations');
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
15
|
+
var DOMLazyTree = require('./DOMLazyTree');
|
|
16
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
17
|
+
var ReactPerf = require('./ReactPerf');
|
|
19
18
|
|
|
20
19
|
var assign = require('./Object.assign');
|
|
21
20
|
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
|
|
22
|
-
var
|
|
21
|
+
var invariant = require('fbjs/lib/invariant');
|
|
23
22
|
var validateDOMNesting = require('./validateDOMNesting');
|
|
24
23
|
|
|
25
24
|
/**
|
|
@@ -28,8 +27,8 @@ var validateDOMNesting = require('./validateDOMNesting');
|
|
|
28
27
|
* - When mounting text into the DOM, adjacent text nodes are merged.
|
|
29
28
|
* - Text nodes cannot be assigned a React root ID.
|
|
30
29
|
*
|
|
31
|
-
* This component is used to wrap strings
|
|
32
|
-
* the same reconciliation that is applied to elements.
|
|
30
|
+
* This component is used to wrap strings between comment nodes so that they
|
|
31
|
+
* can undergo the same reconciliation that is applied to elements.
|
|
33
32
|
*
|
|
34
33
|
* TODO: Investigate representing React components in the DOM with text nodes.
|
|
35
34
|
*
|
|
@@ -37,62 +36,75 @@ var validateDOMNesting = require('./validateDOMNesting');
|
|
|
37
36
|
* @extends ReactComponent
|
|
38
37
|
* @internal
|
|
39
38
|
*/
|
|
40
|
-
var ReactDOMTextComponent = function (
|
|
41
|
-
// This
|
|
39
|
+
var ReactDOMTextComponent = function (text) {
|
|
40
|
+
// TODO: This is really a ReactText (ReactNode), not a ReactElement
|
|
41
|
+
this._currentElement = text;
|
|
42
|
+
this._stringText = '' + text;
|
|
43
|
+
// ReactDOMComponentTree uses these:
|
|
44
|
+
this._nativeNode = null;
|
|
45
|
+
this._nativeParent = null;
|
|
46
|
+
|
|
47
|
+
// Properties
|
|
48
|
+
this._domID = null;
|
|
49
|
+
this._mountIndex = 0;
|
|
50
|
+
this._closingComment = null;
|
|
51
|
+
this._commentNodes = null;
|
|
42
52
|
};
|
|
43
53
|
|
|
44
54
|
assign(ReactDOMTextComponent.prototype, {
|
|
45
55
|
|
|
46
|
-
/**
|
|
47
|
-
* @param {ReactText} text
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
construct: function (text) {
|
|
51
|
-
// TODO: This is really a ReactText (ReactNode), not a ReactElement
|
|
52
|
-
this._currentElement = text;
|
|
53
|
-
this._stringText = '' + text;
|
|
54
|
-
|
|
55
|
-
// Properties
|
|
56
|
-
this._rootNodeID = null;
|
|
57
|
-
this._mountIndex = 0;
|
|
58
|
-
},
|
|
59
|
-
|
|
60
56
|
/**
|
|
61
57
|
* Creates the markup for this text node. This node is not intended to have
|
|
62
58
|
* any features besides containing text content.
|
|
63
59
|
*
|
|
64
|
-
* @param {string} rootID DOM ID of the root node.
|
|
65
60
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
66
61
|
* @return {string} Markup for this text node.
|
|
67
62
|
* @internal
|
|
68
63
|
*/
|
|
69
|
-
mountComponent: function (
|
|
64
|
+
mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
|
|
70
65
|
if (process.env.NODE_ENV !== 'production') {
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
var parentInfo;
|
|
67
|
+
if (nativeParent != null) {
|
|
68
|
+
parentInfo = nativeParent._ancestorInfo;
|
|
69
|
+
} else if (nativeContainerInfo != null) {
|
|
70
|
+
parentInfo = nativeContainerInfo._ancestorInfo;
|
|
71
|
+
}
|
|
72
|
+
if (parentInfo) {
|
|
73
|
+
// parentInfo should always be present except for the top-level
|
|
74
|
+
// component when server rendering
|
|
75
|
+
validateDOMNesting('#text', this, parentInfo);
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
var domID = nativeContainerInfo._idCounter++;
|
|
80
|
+
var openingValue = ' react-text: ' + domID + ' ';
|
|
81
|
+
var closingValue = ' /react-text ';
|
|
82
|
+
this._domID = domID;
|
|
83
|
+
this._nativeParent = nativeParent;
|
|
77
84
|
if (transaction.useCreateElement) {
|
|
78
|
-
var ownerDocument =
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
var ownerDocument = nativeContainerInfo._ownerDocument;
|
|
86
|
+
var openingComment = ownerDocument.createComment(openingValue);
|
|
87
|
+
var closingComment = ownerDocument.createComment(closingValue);
|
|
88
|
+
var lazyTree = DOMLazyTree(ownerDocument.createDocumentFragment());
|
|
89
|
+
DOMLazyTree.queueChild(lazyTree, DOMLazyTree(openingComment));
|
|
90
|
+
if (this._stringText) {
|
|
91
|
+
DOMLazyTree.queueChild(lazyTree, DOMLazyTree(ownerDocument.createTextNode(this._stringText)));
|
|
92
|
+
}
|
|
93
|
+
DOMLazyTree.queueChild(lazyTree, DOMLazyTree(closingComment));
|
|
94
|
+
ReactDOMComponentTree.precacheNode(this, openingComment);
|
|
95
|
+
this._closingComment = closingComment;
|
|
96
|
+
return lazyTree;
|
|
85
97
|
} else {
|
|
86
98
|
var escapedText = escapeTextContentForBrowser(this._stringText);
|
|
87
99
|
|
|
88
100
|
if (transaction.renderToStaticMarkup) {
|
|
89
|
-
// Normally we'd wrap this
|
|
90
|
-
// since this is a situation where React won't take over
|
|
91
|
-
// we can simply return the text as it is.
|
|
101
|
+
// Normally we'd wrap this between comment nodes for the reasons stated
|
|
102
|
+
// above, but since this is a situation where React won't take over
|
|
103
|
+
// (static pages), we can simply return the text as it is.
|
|
92
104
|
return escapedText;
|
|
93
105
|
}
|
|
94
106
|
|
|
95
|
-
return '
|
|
107
|
+
return '<!--' + openingValue + '-->' + escapedText + '<!--' + closingValue + '-->';
|
|
96
108
|
}
|
|
97
109
|
},
|
|
98
110
|
|
|
@@ -112,16 +124,45 @@ assign(ReactDOMTextComponent.prototype, {
|
|
|
112
124
|
// and/or updateComponent to do the actual update for consistency with
|
|
113
125
|
// other component types?
|
|
114
126
|
this._stringText = nextStringText;
|
|
115
|
-
var
|
|
116
|
-
DOMChildrenOperations.
|
|
127
|
+
var commentNodes = this.getNativeNode();
|
|
128
|
+
DOMChildrenOperations.replaceDelimitedText(commentNodes[0], commentNodes[1], nextStringText);
|
|
117
129
|
}
|
|
118
130
|
}
|
|
119
131
|
},
|
|
120
132
|
|
|
133
|
+
getNativeNode: function () {
|
|
134
|
+
var nativeNode = this._commentNodes;
|
|
135
|
+
if (nativeNode) {
|
|
136
|
+
return nativeNode;
|
|
137
|
+
}
|
|
138
|
+
if (!this._closingComment) {
|
|
139
|
+
var openingComment = ReactDOMComponentTree.getNodeFromInstance(this);
|
|
140
|
+
var node = openingComment.nextSibling;
|
|
141
|
+
while (true) {
|
|
142
|
+
!(node != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Missing closing comment for text component %s', this._domID) : invariant(false) : void 0;
|
|
143
|
+
if (node.nodeType === 8 && node.nodeValue === ' /react-text ') {
|
|
144
|
+
this._closingComment = node;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
node = node.nextSibling;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
nativeNode = [this._nativeNode, this._closingComment];
|
|
151
|
+
this._commentNodes = nativeNode;
|
|
152
|
+
return nativeNode;
|
|
153
|
+
},
|
|
154
|
+
|
|
121
155
|
unmountComponent: function () {
|
|
122
|
-
|
|
156
|
+
this._closingComment = null;
|
|
157
|
+
this._commentNodes = null;
|
|
158
|
+
ReactDOMComponentTree.uncacheNode(this);
|
|
123
159
|
}
|
|
124
160
|
|
|
125
161
|
});
|
|
126
162
|
|
|
163
|
+
ReactPerf.measureMethods(ReactDOMTextComponent.prototype, 'ReactDOMTextComponent', {
|
|
164
|
+
mountComponent: 'mountComponent',
|
|
165
|
+
receiveComponent: 'receiveComponent'
|
|
166
|
+
});
|
|
167
|
+
|
|
127
168
|
module.exports = ReactDOMTextComponent;
|
package/lib/ReactDOMTextarea.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
|
|
@@ -11,14 +11,19 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var DOMPropertyOperations = require('./DOMPropertyOperations');
|
|
14
15
|
var LinkedValueUtils = require('./LinkedValueUtils');
|
|
15
|
-
var
|
|
16
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
16
17
|
var ReactUpdates = require('./ReactUpdates');
|
|
17
18
|
|
|
18
19
|
var assign = require('./Object.assign');
|
|
19
20
|
var invariant = require('fbjs/lib/invariant');
|
|
20
21
|
var warning = require('fbjs/lib/warning');
|
|
21
22
|
|
|
23
|
+
var didWarnValueLink = false;
|
|
24
|
+
var didWarnValueNull = false;
|
|
25
|
+
var didWarnValDefaultVal = false;
|
|
26
|
+
|
|
22
27
|
function forceUpdateIfMounted() {
|
|
23
28
|
if (this._rootNodeID) {
|
|
24
29
|
// DOM component is still mounted; update
|
|
@@ -26,6 +31,14 @@ function forceUpdateIfMounted() {
|
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
function warnIfValueIsNull(props) {
|
|
35
|
+
if (props != null && props.value === null && !didWarnValueNull) {
|
|
36
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '`value` prop on `textarea` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.') : void 0;
|
|
37
|
+
|
|
38
|
+
didWarnValueNull = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
29
42
|
/**
|
|
30
43
|
* Implements a <textarea> native component that allows setting `value`, and
|
|
31
44
|
* `defaultValue`. This differs from the traditional DOM API because value is
|
|
@@ -42,8 +55,8 @@ function forceUpdateIfMounted() {
|
|
|
42
55
|
* `defaultValue` if specified, or the children content (deprecated).
|
|
43
56
|
*/
|
|
44
57
|
var ReactDOMTextarea = {
|
|
45
|
-
getNativeProps: function (inst, props
|
|
46
|
-
!(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) :
|
|
58
|
+
getNativeProps: function (inst, props) {
|
|
59
|
+
!(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : void 0;
|
|
47
60
|
|
|
48
61
|
// Always set children to the same thing. In IE9, the selection range will
|
|
49
62
|
// get reset if `textContent` is mutated.
|
|
@@ -60,6 +73,15 @@ var ReactDOMTextarea = {
|
|
|
60
73
|
mountWrapper: function (inst, props) {
|
|
61
74
|
if (process.env.NODE_ENV !== 'production') {
|
|
62
75
|
LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
|
|
76
|
+
if (props.valueLink !== undefined && !didWarnValueLink) {
|
|
77
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `textarea` is deprecated; set `value` and `onChange` instead.') : void 0;
|
|
78
|
+
didWarnValueLink = true;
|
|
79
|
+
}
|
|
80
|
+
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
|
|
81
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components') : void 0;
|
|
82
|
+
didWarnValDefaultVal = true;
|
|
83
|
+
}
|
|
84
|
+
warnIfValueIsNull(props);
|
|
63
85
|
}
|
|
64
86
|
|
|
65
87
|
var defaultValue = props.defaultValue;
|
|
@@ -67,11 +89,11 @@ var ReactDOMTextarea = {
|
|
|
67
89
|
var children = props.children;
|
|
68
90
|
if (children != null) {
|
|
69
91
|
if (process.env.NODE_ENV !== 'production') {
|
|
70
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') :
|
|
92
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : void 0;
|
|
71
93
|
}
|
|
72
|
-
!(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) :
|
|
94
|
+
!(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : void 0;
|
|
73
95
|
if (Array.isArray(children)) {
|
|
74
|
-
!(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) :
|
|
96
|
+
!(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : void 0;
|
|
75
97
|
children = children[0];
|
|
76
98
|
}
|
|
77
99
|
|
|
@@ -81,24 +103,29 @@ var ReactDOMTextarea = {
|
|
|
81
103
|
defaultValue = '';
|
|
82
104
|
}
|
|
83
105
|
var value = LinkedValueUtils.getValue(props);
|
|
84
|
-
|
|
85
106
|
inst._wrapperState = {
|
|
86
107
|
// We save the initial value so that `ReactDOMComponent` doesn't update
|
|
87
108
|
// `textContent` (unnecessary since we update value).
|
|
88
109
|
// The initial value can be a boolean or object so that's why it's
|
|
89
110
|
// forced to be a string.
|
|
90
111
|
initialValue: '' + (value != null ? value : defaultValue),
|
|
112
|
+
listeners: null,
|
|
91
113
|
onChange: _handleChange.bind(inst)
|
|
92
114
|
};
|
|
93
115
|
},
|
|
94
116
|
|
|
95
117
|
updateWrapper: function (inst) {
|
|
96
118
|
var props = inst._currentElement.props;
|
|
119
|
+
|
|
120
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
121
|
+
warnIfValueIsNull(props);
|
|
122
|
+
}
|
|
123
|
+
|
|
97
124
|
var value = LinkedValueUtils.getValue(props);
|
|
98
125
|
if (value != null) {
|
|
99
126
|
// Cast `value` to a string to ensure the value is set correctly. While
|
|
100
127
|
// browsers typically do this as necessary, jsdom doesn't.
|
|
101
|
-
|
|
128
|
+
DOMPropertyOperations.setValueForProperty(ReactDOMComponentTree.getNodeFromInstance(inst), 'value', '' + value);
|
|
102
129
|
}
|
|
103
130
|
}
|
|
104
131
|
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactDOMTreeTraversal
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var invariant = require('fbjs/lib/invariant');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Return the lowest common ancestor of A and B, or null if they are in
|
|
18
|
+
* different trees.
|
|
19
|
+
*/
|
|
20
|
+
function getLowestCommonAncestor(instA, instB) {
|
|
21
|
+
!('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : void 0;
|
|
22
|
+
!('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : void 0;
|
|
23
|
+
|
|
24
|
+
var depthA = 0;
|
|
25
|
+
for (var tempA = instA; tempA; tempA = tempA._nativeParent) {
|
|
26
|
+
depthA++;
|
|
27
|
+
}
|
|
28
|
+
var depthB = 0;
|
|
29
|
+
for (var tempB = instB; tempB; tempB = tempB._nativeParent) {
|
|
30
|
+
depthB++;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// If A is deeper, crawl up.
|
|
34
|
+
while (depthA - depthB > 0) {
|
|
35
|
+
instA = instA._nativeParent;
|
|
36
|
+
depthA--;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// If B is deeper, crawl up.
|
|
40
|
+
while (depthB - depthA > 0) {
|
|
41
|
+
instB = instB._nativeParent;
|
|
42
|
+
depthB--;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Walk in lockstep until we find a match.
|
|
46
|
+
var depth = depthA;
|
|
47
|
+
while (depth--) {
|
|
48
|
+
if (instA === instB) {
|
|
49
|
+
return instA;
|
|
50
|
+
}
|
|
51
|
+
instA = instA._nativeParent;
|
|
52
|
+
instB = instB._nativeParent;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Return if A is an ancestor of B.
|
|
59
|
+
*/
|
|
60
|
+
function isAncestor(instA, instB) {
|
|
61
|
+
!('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) : void 0;
|
|
62
|
+
!('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) : void 0;
|
|
63
|
+
|
|
64
|
+
while (instB) {
|
|
65
|
+
if (instB === instA) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
instB = instB._nativeParent;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Return the parent instance of the passed-in instance.
|
|
75
|
+
*/
|
|
76
|
+
function getParentInstance(inst) {
|
|
77
|
+
!('_nativeNode' in inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getParentInstance: Invalid argument.') : invariant(false) : void 0;
|
|
78
|
+
|
|
79
|
+
return inst._nativeParent;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Simulates the traversal of a two-phase, capture/bubble event dispatch.
|
|
84
|
+
*/
|
|
85
|
+
function traverseTwoPhase(inst, fn, arg) {
|
|
86
|
+
var path = [];
|
|
87
|
+
while (inst) {
|
|
88
|
+
path.push(inst);
|
|
89
|
+
inst = inst._nativeParent;
|
|
90
|
+
}
|
|
91
|
+
var i;
|
|
92
|
+
for (i = path.length; i-- > 0;) {
|
|
93
|
+
fn(path[i], false, arg);
|
|
94
|
+
}
|
|
95
|
+
for (i = 0; i < path.length; i++) {
|
|
96
|
+
fn(path[i], true, arg);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
|
|
102
|
+
* should would receive a `mouseEnter` or `mouseLeave` event.
|
|
103
|
+
*
|
|
104
|
+
* Does not invoke the callback on the nearest common ancestor because nothing
|
|
105
|
+
* "entered" or "left" that element.
|
|
106
|
+
*/
|
|
107
|
+
function traverseEnterLeave(from, to, fn, argFrom, argTo) {
|
|
108
|
+
var common = from && to ? getLowestCommonAncestor(from, to) : null;
|
|
109
|
+
var pathFrom = [];
|
|
110
|
+
while (from && from !== common) {
|
|
111
|
+
pathFrom.push(from);
|
|
112
|
+
from = from._nativeParent;
|
|
113
|
+
}
|
|
114
|
+
var pathTo = [];
|
|
115
|
+
while (to && to !== common) {
|
|
116
|
+
pathTo.push(to);
|
|
117
|
+
to = to._nativeParent;
|
|
118
|
+
}
|
|
119
|
+
var i;
|
|
120
|
+
for (i = 0; i < pathFrom.length; i++) {
|
|
121
|
+
fn(pathFrom[i], true, argFrom);
|
|
122
|
+
}
|
|
123
|
+
for (i = pathTo.length; i-- > 0;) {
|
|
124
|
+
fn(pathTo[i], false, argTo);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = {
|
|
129
|
+
isAncestor: isAncestor,
|
|
130
|
+
getLowestCommonAncestor: getLowestCommonAncestor,
|
|
131
|
+
getParentInstance: getParentInstance,
|
|
132
|
+
traverseTwoPhase: traverseTwoPhase,
|
|
133
|
+
traverseEnterLeave: traverseEnterLeave
|
|
134
|
+
};
|