react 0.14.0-alpha2 → 0.14.0-beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/addons.js +6 -3
- package/dist/JSXTransformer.js +634 -274
- package/dist/react-with-addons.js +5350 -4954
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4777 -4408
- package/dist/react.min.js +6 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +3 -0
- package/lib/CSSPropertyOperations.js +13 -13
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +16 -14
- package/lib/DOMChildrenOperations.js +10 -6
- package/lib/DOMProperty.js +82 -117
- package/lib/DOMPropertyOperations.js +78 -33
- package/lib/Danger.js +14 -14
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +8 -8
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +13 -13
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +17 -17
- package/lib/EventPropagators.js +7 -7
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +13 -3
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +50 -38
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +14 -2
- package/lib/React.js +6 -6
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +16 -5
- package/lib/ReactCSSTransitionGroupChild.js +20 -11
- package/lib/ReactChildReconciler.js +25 -18
- package/lib/ReactChildren.js +9 -9
- package/lib/ReactClass.js +65 -83
- package/lib/ReactComponent.js +22 -17
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +80 -111
- package/lib/ReactDOM.js +72 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +378 -56
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/ReactDOMIDOperations.js +23 -23
- package/lib/ReactDOMInput.js +83 -99
- package/lib/ReactDOMOption.js +25 -45
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +2 -2
- package/lib/ReactDOMTextComponent.js +11 -11
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +24 -71
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -9
- package/lib/ReactElement.js +22 -83
- package/lib/ReactElementValidator.js +48 -117
- package/lib/ReactEmptyComponent.js +4 -4
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +57 -12
- package/lib/ReactFragment.js +22 -17
- package/lib/ReactInjection.js +11 -11
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +11 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +88 -88
- package/lib/ReactMultiChild.js +83 -22
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -8
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +49 -11
- package/lib/ReactReconcileTransaction.js +8 -8
- package/lib/ReactReconciler.js +18 -20
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +7 -7
- package/lib/ReactTestUtils.js +80 -58
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +61 -36
- package/lib/ReactUpdates.js +14 -17
- package/lib/ReactWithAddons.js +14 -16
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +14 -15
- package/lib/SimpleEventPlugin.js +205 -29
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +9 -8
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +3 -3
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +5 -5
- package/lib/SyntheticTouchEvent.js +4 -4
- package/lib/SyntheticUIEvent.js +4 -4
- package/lib/SyntheticWheelEvent.js +3 -3
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +16 -10
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +47 -0
- package/lib/findDOMNode.js +11 -12
- package/lib/flattenChildren.js +4 -4
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +24 -20
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +210 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +2 -2
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/sliceChildren.js +51 -0
- package/lib/traverseAllChildren.js +15 -14
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +14 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +53 -1
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- package/lib/ReactDOMClient.js +0 -85
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createFullPageComponent.js +0 -51
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/emptyObject.js +0 -20
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -115
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/isTextNode.js +0 -25
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/performance.js +0 -23
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -61
package/lib/ReactDOMOption.js
CHANGED
|
@@ -11,96 +11,76 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var ReactClass = require("./ReactClass");
|
|
17
|
-
var ReactDOMSelect = require("./ReactDOMSelect");
|
|
18
|
-
var ReactElement = require("./ReactElement");
|
|
19
|
-
var ReactInstanceMap = require("./ReactInstanceMap");
|
|
20
|
-
var ReactPropTypes = require("./ReactPropTypes");
|
|
14
|
+
var ReactChildren = require('./ReactChildren');
|
|
15
|
+
var ReactDOMSelect = require('./ReactDOMSelect');
|
|
21
16
|
|
|
22
|
-
var assign = require(
|
|
23
|
-
var warning = require(
|
|
24
|
-
|
|
25
|
-
var option = ReactElement.createFactory('option');
|
|
17
|
+
var assign = require('./Object.assign');
|
|
18
|
+
var warning = require('fbjs/lib/warning');
|
|
26
19
|
|
|
27
20
|
var valueContextKey = ReactDOMSelect.valueContextKey;
|
|
28
21
|
|
|
29
22
|
/**
|
|
30
23
|
* Implements an <option> native component that warns when `selected` is set.
|
|
31
24
|
*/
|
|
32
|
-
var ReactDOMOption =
|
|
33
|
-
|
|
34
|
-
tagName: 'OPTION',
|
|
35
|
-
|
|
36
|
-
mixins: [ReactBrowserComponentMixin],
|
|
37
|
-
|
|
38
|
-
getInitialState: function () {
|
|
39
|
-
return { selected: null };
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
contextTypes: (function () {
|
|
43
|
-
var obj = {};
|
|
44
|
-
obj[valueContextKey] = ReactPropTypes.any;
|
|
45
|
-
return obj;
|
|
46
|
-
})(),
|
|
47
|
-
|
|
48
|
-
componentWillMount: function () {
|
|
25
|
+
var ReactDOMOption = {
|
|
26
|
+
mountWrapper: function (inst, props, context) {
|
|
49
27
|
// TODO (yungsters): Remove support for `selected` in <option>.
|
|
50
|
-
if (
|
|
51
|
-
|
|
28
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
29
|
+
process.env.NODE_ENV !== 'production' ? warning(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.') : undefined;
|
|
52
30
|
}
|
|
53
31
|
|
|
54
|
-
// Look up whether this option is 'selected' via
|
|
55
|
-
var context = ReactInstanceMap.get(this)._context;
|
|
32
|
+
// Look up whether this option is 'selected' via context
|
|
56
33
|
var selectValue = context[valueContextKey];
|
|
57
34
|
|
|
58
35
|
// If context key is null (e.g., no specified value or after initial mount)
|
|
59
|
-
// or missing (e.g., for <datalist>)
|
|
36
|
+
// or missing (e.g., for <datalist>), we don't change props.selected
|
|
37
|
+
var selected = null;
|
|
60
38
|
if (selectValue != null) {
|
|
61
|
-
|
|
39
|
+
selected = false;
|
|
62
40
|
if (Array.isArray(selectValue)) {
|
|
63
41
|
// multiple
|
|
64
42
|
for (var i = 0; i < selectValue.length; i++) {
|
|
65
|
-
if ('' + selectValue[i] === '' +
|
|
43
|
+
if ('' + selectValue[i] === '' + props.value) {
|
|
66
44
|
selected = true;
|
|
67
45
|
break;
|
|
68
46
|
}
|
|
69
47
|
}
|
|
70
48
|
} else {
|
|
71
|
-
selected = '' + selectValue === '' +
|
|
49
|
+
selected = '' + selectValue === '' + props.value;
|
|
72
50
|
}
|
|
73
|
-
this.setState({ selected: selected });
|
|
74
51
|
}
|
|
52
|
+
|
|
53
|
+
inst._wrapperState = { selected: selected };
|
|
75
54
|
},
|
|
76
55
|
|
|
77
|
-
|
|
78
|
-
var
|
|
56
|
+
getNativeProps: function (inst, props, context) {
|
|
57
|
+
var nativeProps = assign({ selected: undefined, children: undefined }, props);
|
|
79
58
|
|
|
80
59
|
// Read state only from initial mount because <select> updates value
|
|
81
60
|
// manually; we need the initial state only for server rendering
|
|
82
|
-
if (
|
|
83
|
-
|
|
61
|
+
if (inst._wrapperState.selected != null) {
|
|
62
|
+
nativeProps.selected = inst._wrapperState.selected;
|
|
84
63
|
}
|
|
85
64
|
|
|
86
65
|
var content = '';
|
|
87
66
|
|
|
88
67
|
// Flatten children and warn if they aren't strings or numbers;
|
|
89
68
|
// invalid types are ignored.
|
|
90
|
-
ReactChildren.forEach(
|
|
69
|
+
ReactChildren.forEach(props.children, function (child) {
|
|
91
70
|
if (child == null) {
|
|
92
71
|
return;
|
|
93
72
|
}
|
|
94
73
|
if (typeof child === 'string' || typeof child === 'number') {
|
|
95
74
|
content += child;
|
|
96
75
|
} else {
|
|
97
|
-
|
|
76
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Only strings and numbers are supported as <option> children.') : undefined;
|
|
98
77
|
}
|
|
99
78
|
});
|
|
100
79
|
|
|
101
|
-
|
|
80
|
+
nativeProps.children = content;
|
|
81
|
+
return nativeProps;
|
|
102
82
|
}
|
|
103
83
|
|
|
104
|
-
}
|
|
84
|
+
};
|
|
105
85
|
|
|
106
86
|
module.exports = ReactDOMOption;
|
package/lib/ReactDOMSelect.js
CHANGED
|
@@ -11,61 +11,72 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var ReactClass = require("./ReactClass");
|
|
18
|
-
var ReactElement = require("./ReactElement");
|
|
19
|
-
var ReactUpdates = require("./ReactUpdates");
|
|
20
|
-
var ReactPropTypes = require("./ReactPropTypes");
|
|
14
|
+
var LinkedValueUtils = require('./LinkedValueUtils');
|
|
15
|
+
var ReactMount = require('./ReactMount');
|
|
16
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
21
17
|
|
|
22
|
-
var assign = require(
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
var select = ReactElement.createFactory('select');
|
|
18
|
+
var assign = require('./Object.assign');
|
|
19
|
+
var warning = require('fbjs/lib/warning');
|
|
26
20
|
|
|
27
21
|
var valueContextKey = '__ReactDOMSelect_value$' + Math.random().toString(36).slice(2);
|
|
28
22
|
|
|
29
23
|
function updateOptionsIfPendingUpdateAndMounted() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
if (this._wrapperState.pendingUpdate && this._rootNodeID) {
|
|
25
|
+
this._wrapperState.pendingUpdate = false;
|
|
26
|
+
|
|
27
|
+
var props = this._currentElement.props;
|
|
28
|
+
var value = LinkedValueUtils.getValue(props);
|
|
29
|
+
|
|
30
|
+
if (value != null) {
|
|
31
|
+
updateOptions(this, props, value);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
|
|
36
|
+
function getDeclarationErrorAddendum(owner) {
|
|
37
|
+
if (owner) {
|
|
38
|
+
var name = owner.getName();
|
|
39
|
+
if (name) {
|
|
40
|
+
return ' Check the render method of `' + name + '`.';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var valuePropNames = ['value', 'defaultValue'];
|
|
47
|
+
|
|
40
48
|
/**
|
|
41
49
|
* Validation function for `value` and `defaultValue`.
|
|
42
50
|
* @private
|
|
43
51
|
*/
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
function checkSelectPropTypes(inst, props) {
|
|
53
|
+
var owner = inst._currentElement._owner;
|
|
54
|
+
LinkedValueUtils.checkPropTypes('select', props, owner);
|
|
55
|
+
|
|
56
|
+
for (var i = 0; i < valuePropNames.length; i++) {
|
|
57
|
+
var propName = valuePropNames[i];
|
|
58
|
+
if (props[propName] == null) {
|
|
59
|
+
continue;
|
|
51
60
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
if (props.multiple) {
|
|
62
|
+
process.env.NODE_ENV !== 'production' ? warning(Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : undefined;
|
|
63
|
+
} else {
|
|
64
|
+
process.env.NODE_ENV !== 'production' ? warning(!Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : undefined;
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
/**
|
|
60
|
-
* @param {
|
|
70
|
+
* @param {ReactDOMComponent} inst
|
|
71
|
+
* @param {boolean} multiple
|
|
61
72
|
* @param {*} propValue A stringable (with `multiple`, a list of stringables).
|
|
62
73
|
* @private
|
|
63
74
|
*/
|
|
64
|
-
function updateOptions(
|
|
75
|
+
function updateOptions(inst, multiple, propValue) {
|
|
65
76
|
var selectedValue, i;
|
|
66
|
-
var options =
|
|
77
|
+
var options = ReactMount.getNode(inst._rootNodeID).options;
|
|
67
78
|
|
|
68
|
-
if (
|
|
79
|
+
if (multiple) {
|
|
69
80
|
selectedValue = {};
|
|
70
81
|
for (i = 0; i < propValue.length; i++) {
|
|
71
82
|
selectedValue['' + propValue[i]] = true;
|
|
@@ -107,92 +118,71 @@ function updateOptions(component, propValue) {
|
|
|
107
118
|
* If `defaultValue` is provided, any options with the supplied values will be
|
|
108
119
|
* selected.
|
|
109
120
|
*/
|
|
110
|
-
var ReactDOMSelect =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
var ReactDOMSelect = {
|
|
122
|
+
valueContextKey: valueContextKey,
|
|
123
|
+
|
|
124
|
+
getNativeProps: function (inst, props, context) {
|
|
125
|
+
return assign({}, props, {
|
|
126
|
+
onChange: inst._wrapperState.onChange,
|
|
127
|
+
value: undefined
|
|
128
|
+
});
|
|
118
129
|
},
|
|
119
130
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
getInitialState: function () {
|
|
126
|
-
// Pass down initial value so initial generated markup has correct
|
|
127
|
-
// `selected` attributes
|
|
128
|
-
var value = LinkedValueUtils.getValue(this.props);
|
|
129
|
-
if (value != null) {
|
|
130
|
-
return { initialValue: value };
|
|
131
|
-
} else {
|
|
132
|
-
return { initialValue: this.props.defaultValue };
|
|
131
|
+
mountWrapper: function (inst, props) {
|
|
132
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
133
|
+
checkSelectPropTypes(inst, props);
|
|
133
134
|
}
|
|
134
|
-
},
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
var obj = {};
|
|
144
|
-
obj[valueContextKey] = this.state.initialValue;
|
|
145
|
-
return obj;
|
|
136
|
+
var value = LinkedValueUtils.getValue(props);
|
|
137
|
+
inst._wrapperState = {
|
|
138
|
+
pendingUpdate: false,
|
|
139
|
+
initialValue: value != null ? value : props.defaultValue,
|
|
140
|
+
onChange: _handleChange.bind(inst),
|
|
141
|
+
wasMultiple: Boolean(props.multiple)
|
|
142
|
+
};
|
|
146
143
|
},
|
|
147
144
|
|
|
148
|
-
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return select(props, this.props.children);
|
|
145
|
+
processChildContext: function (inst, props, context) {
|
|
146
|
+
// Pass down initial value so initial generated markup has correct
|
|
147
|
+
// `selected` attributes
|
|
148
|
+
var childContext = assign({}, context);
|
|
149
|
+
childContext[valueContextKey] = inst._wrapperState.initialValue;
|
|
150
|
+
return childContext;
|
|
156
151
|
},
|
|
157
152
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
},
|
|
153
|
+
postUpdateWrapper: function (inst) {
|
|
154
|
+
var props = inst._currentElement.props;
|
|
161
155
|
|
|
162
|
-
componentWillReceiveProps: function (nextProps) {
|
|
163
156
|
// After the initial mount, we control selected-ness manually so don't pass
|
|
164
157
|
// the context value down
|
|
165
|
-
|
|
166
|
-
|
|
158
|
+
inst._wrapperState.initialValue = undefined;
|
|
159
|
+
|
|
160
|
+
var wasMultiple = inst._wrapperState.wasMultiple;
|
|
161
|
+
inst._wrapperState.wasMultiple = Boolean(props.multiple);
|
|
167
162
|
|
|
168
|
-
|
|
169
|
-
var value = LinkedValueUtils.getValue(this.props);
|
|
163
|
+
var value = LinkedValueUtils.getValue(props);
|
|
170
164
|
if (value != null) {
|
|
171
|
-
|
|
172
|
-
updateOptions(
|
|
173
|
-
} else if (
|
|
165
|
+
inst._wrapperState.pendingUpdate = false;
|
|
166
|
+
updateOptions(inst, Boolean(props.multiple), value);
|
|
167
|
+
} else if (wasMultiple !== Boolean(props.multiple)) {
|
|
174
168
|
// For simplicity, reapply `defaultValue` if `multiple` is toggled.
|
|
175
|
-
if (
|
|
176
|
-
updateOptions(
|
|
169
|
+
if (props.defaultValue != null) {
|
|
170
|
+
updateOptions(inst, Boolean(props.multiple), props.defaultValue);
|
|
177
171
|
} else {
|
|
178
172
|
// Revert the select back to its default unselected state.
|
|
179
|
-
updateOptions(
|
|
173
|
+
updateOptions(inst, Boolean(props.multiple), props.multiple ? [] : '');
|
|
180
174
|
}
|
|
181
175
|
}
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
_handleChange: function (event) {
|
|
185
|
-
var returnValue;
|
|
186
|
-
var onChange = LinkedValueUtils.getOnChange(this.props);
|
|
187
|
-
if (onChange) {
|
|
188
|
-
returnValue = onChange.call(this, event);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
this._pendingUpdate = true;
|
|
192
|
-
ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
|
|
193
|
-
return returnValue;
|
|
194
176
|
}
|
|
177
|
+
};
|
|
195
178
|
|
|
196
|
-
|
|
179
|
+
function _handleChange(event) {
|
|
180
|
+
var props = this._currentElement.props;
|
|
181
|
+
var returnValue = LinkedValueUtils.executeOnChange(props, event);
|
|
182
|
+
|
|
183
|
+
this._wrapperState.pendingUpdate = true;
|
|
184
|
+
ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
|
|
185
|
+
return returnValue;
|
|
186
|
+
}
|
|
197
187
|
|
|
198
188
|
module.exports = ReactDOMSelect;
|
package/lib/ReactDOMSelection.js
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ExecutionEnvironment = require(
|
|
14
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
15
15
|
|
|
16
|
-
var getNodeForCharacterOffset = require(
|
|
17
|
-
var getTextContentAccessor = require(
|
|
16
|
+
var getNodeForCharacterOffset = require('./getNodeForCharacterOffset');
|
|
17
|
+
var getTextContentAccessor = require('./getTextContentAccessor');
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* While `isCollapsed` is available on the Selection object and `collapsed`
|
package/lib/ReactDOMServer.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactDefaultInjection = require(
|
|
15
|
-
var ReactServerRendering = require(
|
|
14
|
+
var ReactDefaultInjection = require('./ReactDefaultInjection');
|
|
15
|
+
var ReactServerRendering = require('./ReactServerRendering');
|
|
16
16
|
|
|
17
17
|
ReactDefaultInjection.inject();
|
|
18
18
|
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var DOMPropertyOperations = require(
|
|
16
|
-
var ReactComponentBrowserEnvironment = require(
|
|
17
|
-
var ReactDOMComponent = require(
|
|
15
|
+
var DOMPropertyOperations = require('./DOMPropertyOperations');
|
|
16
|
+
var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
|
|
17
|
+
var ReactDOMComponent = require('./ReactDOMComponent');
|
|
18
18
|
|
|
19
|
-
var assign = require(
|
|
20
|
-
var escapeTextContentForBrowser = require(
|
|
21
|
-
var validateDOMNesting = require(
|
|
19
|
+
var assign = require('./Object.assign');
|
|
20
|
+
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
|
|
21
|
+
var validateDOMNesting = require('./validateDOMNesting');
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Text nodes violate a couple assumptions that React makes about components:
|
|
@@ -35,7 +35,9 @@ var validateDOMNesting = require("./validateDOMNesting");
|
|
|
35
35
|
* @extends ReactComponent
|
|
36
36
|
* @internal
|
|
37
37
|
*/
|
|
38
|
-
var ReactDOMTextComponent = function (props) {
|
|
38
|
+
var ReactDOMTextComponent = function (props) {
|
|
39
|
+
// This constructor and its argument is currently used by mocks.
|
|
40
|
+
};
|
|
39
41
|
|
|
40
42
|
assign(ReactDOMTextComponent.prototype, {
|
|
41
43
|
|
|
@@ -63,7 +65,7 @@ assign(ReactDOMTextComponent.prototype, {
|
|
|
63
65
|
* @internal
|
|
64
66
|
*/
|
|
65
67
|
mountComponent: function (rootID, transaction, context) {
|
|
66
|
-
if (
|
|
68
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
67
69
|
if (context[validateDOMNesting.ancestorInfoContextKey]) {
|
|
68
70
|
validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]);
|
|
69
71
|
}
|
|
@@ -109,6 +111,4 @@ assign(ReactDOMTextComponent.prototype, {
|
|
|
109
111
|
|
|
110
112
|
});
|
|
111
113
|
|
|
112
|
-
module.exports = ReactDOMTextComponent;
|
|
113
|
-
|
|
114
|
-
// This constructor and its argument is currently used by mocks.
|
|
114
|
+
module.exports = ReactDOMTextComponent;
|
package/lib/ReactDOMTextarea.js
CHANGED
|
@@ -11,26 +11,18 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
18
|
-
var ReactClass = require("./ReactClass");
|
|
19
|
-
var ReactElement = require("./ReactElement");
|
|
20
|
-
var ReactUpdates = require("./ReactUpdates");
|
|
14
|
+
var LinkedValueUtils = require('./LinkedValueUtils');
|
|
15
|
+
var ReactDOMIDOperations = require('./ReactDOMIDOperations');
|
|
16
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
21
17
|
|
|
22
|
-
var assign = require(
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
var warning = require("./warning");
|
|
27
|
-
|
|
28
|
-
var textarea = ReactElement.createFactory('textarea');
|
|
18
|
+
var assign = require('./Object.assign');
|
|
19
|
+
var invariant = require('fbjs/lib/invariant');
|
|
20
|
+
var warning = require('fbjs/lib/warning');
|
|
29
21
|
|
|
30
22
|
function forceUpdateIfMounted() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
if (this._rootNodeID) {
|
|
24
|
+
// DOM component is still mounted; update
|
|
25
|
+
ReactDOMTextarea.updateWrapper(this);
|
|
34
26
|
}
|
|
35
27
|
}
|
|
36
28
|
|
|
@@ -49,23 +41,35 @@ function forceUpdateIfMounted() {
|
|
|
49
41
|
* The rendered element will be initialized with an empty value, the prop
|
|
50
42
|
* `defaultValue` if specified, or the children content (deprecated).
|
|
51
43
|
*/
|
|
52
|
-
var ReactDOMTextarea =
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
var ReactDOMTextarea = {
|
|
45
|
+
getNativeProps: function (inst, props, context) {
|
|
46
|
+
!(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : undefined;
|
|
55
47
|
|
|
56
|
-
|
|
48
|
+
// Always set children to the same thing. In IE9, the selection range will
|
|
49
|
+
// get reset if `textContent` is mutated.
|
|
50
|
+
var nativeProps = assign({}, props, {
|
|
51
|
+
defaultValue: undefined,
|
|
52
|
+
value: undefined,
|
|
53
|
+
children: inst._wrapperState.initialValue,
|
|
54
|
+
onChange: inst._wrapperState.onChange
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return nativeProps;
|
|
58
|
+
},
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
mountWrapper: function (inst, props) {
|
|
61
|
+
LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
|
|
62
|
+
|
|
63
|
+
var defaultValue = props.defaultValue;
|
|
60
64
|
// TODO (yungsters): Remove support for children content in <textarea>.
|
|
61
|
-
var children =
|
|
65
|
+
var children = props.children;
|
|
62
66
|
if (children != null) {
|
|
63
|
-
if (
|
|
64
|
-
|
|
67
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
68
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : undefined;
|
|
65
69
|
}
|
|
66
|
-
|
|
70
|
+
!(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : undefined;
|
|
67
71
|
if (Array.isArray(children)) {
|
|
68
|
-
|
|
72
|
+
!(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : undefined;
|
|
69
73
|
children = children[0];
|
|
70
74
|
}
|
|
71
75
|
|
|
@@ -74,51 +78,34 @@ var ReactDOMTextarea = ReactClass.createClass({
|
|
|
74
78
|
if (defaultValue == null) {
|
|
75
79
|
defaultValue = '';
|
|
76
80
|
}
|
|
77
|
-
var value = LinkedValueUtils.getValue(
|
|
78
|
-
|
|
81
|
+
var value = LinkedValueUtils.getValue(props);
|
|
82
|
+
|
|
83
|
+
inst._wrapperState = {
|
|
79
84
|
// We save the initial value so that `ReactDOMComponent` doesn't update
|
|
80
85
|
// `textContent` (unnecessary since we update value).
|
|
81
86
|
// The initial value can be a boolean or object so that's why it's
|
|
82
87
|
// forced to be a string.
|
|
83
|
-
initialValue: '' + (value != null ? value : defaultValue)
|
|
88
|
+
initialValue: '' + (value != null ? value : defaultValue),
|
|
89
|
+
onChange: _handleChange.bind(inst)
|
|
84
90
|
};
|
|
85
91
|
},
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
'production' !== process.env.NODE_ENV ? invariant(props.dangerouslySetInnerHTML == null, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(props.dangerouslySetInnerHTML == null);
|
|
92
|
-
|
|
93
|
-
props.defaultValue = null;
|
|
94
|
-
props.value = null;
|
|
95
|
-
props.onChange = this._handleChange;
|
|
96
|
-
|
|
97
|
-
// Always set children to the same thing. In IE9, the selection range will
|
|
98
|
-
// get reset if `textContent` is mutated.
|
|
99
|
-
return textarea(props, this.state.initialValue);
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
componentDidUpdate: function (prevProps, prevState, prevContext) {
|
|
103
|
-
var value = LinkedValueUtils.getValue(this.props);
|
|
93
|
+
updateWrapper: function (inst) {
|
|
94
|
+
var props = inst._currentElement.props;
|
|
95
|
+
var value = LinkedValueUtils.getValue(props);
|
|
104
96
|
if (value != null) {
|
|
105
|
-
var rootNode = findDOMNode(this);
|
|
106
97
|
// Cast `value` to a string to ensure the value is set correctly. While
|
|
107
98
|
// browsers typically do this as necessary, jsdom doesn't.
|
|
108
|
-
|
|
99
|
+
ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value);
|
|
109
100
|
}
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
_handleChange: function (event) {
|
|
113
|
-
var returnValue;
|
|
114
|
-
var onChange = LinkedValueUtils.getOnChange(this.props);
|
|
115
|
-
if (onChange) {
|
|
116
|
-
returnValue = onChange.call(this, event);
|
|
117
|
-
}
|
|
118
|
-
ReactUpdates.asap(forceUpdateIfMounted, this);
|
|
119
|
-
return returnValue;
|
|
120
101
|
}
|
|
102
|
+
};
|
|
121
103
|
|
|
122
|
-
|
|
104
|
+
function _handleChange(event) {
|
|
105
|
+
var props = this._currentElement.props;
|
|
106
|
+
var returnValue = LinkedValueUtils.executeOnChange(props, event);
|
|
107
|
+
ReactUpdates.asap(forceUpdateIfMounted, this);
|
|
108
|
+
return returnValue;
|
|
109
|
+
}
|
|
123
110
|
|
|
124
111
|
module.exports = ReactDOMTextarea;
|