react 15.3.1 → 15.4.0-rc.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/react-with-addons.js +3901 -21391
- package/dist/react-with-addons.min.js +3 -6
- package/dist/react.js +2671 -19498
- package/dist/react.min.js +2 -6
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/PooledClass.js +3 -0
- package/lib/ReactAddonsDOMDependencies.js +36 -0
- package/lib/ReactAddonsDOMDependenciesUMDShim.js +32 -0
- package/lib/ReactCSSTransitionGroup.js +60 -42
- package/lib/ReactCSSTransitionGroupChild.js +2 -2
- package/lib/ReactClass.js +38 -53
- package/lib/ReactComponentTreeHook.js +84 -100
- package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +5 -7
- package/lib/ReactCurrentOwner.js +1 -1
- package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +6 -4
- package/lib/ReactElement.js +6 -29
- package/lib/ReactElementSymbol.js +20 -0
- package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +4 -9
- package/lib/ReactElementValidator.js +1 -2
- package/lib/ReactPropTypeLocationNames.js +1 -0
- package/lib/ReactPropTypeLocations.js +2 -11
- package/lib/ReactPropTypes.js +5 -2
- package/lib/ReactPropTypesSecret.js +1 -0
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +145 -141
- package/lib/ReactUMDEntry.js +11 -5
- package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +4 -6
- package/lib/ReactVersion.js +1 -1
- package/lib/ReactWithAddons.js +15 -2
- package/lib/ReactWithAddonsUMDEntry.js +11 -5
- package/lib/canDefineProperty.js +2 -0
- package/lib/traverseAllChildren.js +11 -2
- package/lib/update.js +6 -7
- package/package.json +1 -1
- package/lib/AutoFocusUtils.js +0 -24
- package/lib/BeforeInputEventPlugin.js +0 -388
- package/lib/CSSProperty.js +0 -148
- package/lib/CSSPropertyOperations.js +0 -205
- package/lib/CallbackQueue.js +0 -106
- package/lib/ChangeEventPlugin.js +0 -325
- package/lib/DOMChildrenOperations.js +0 -194
- package/lib/DOMLazyTree.js +0 -118
- package/lib/DOMProperty.js +0 -206
- package/lib/DOMPropertyOperations.js +0 -221
- package/lib/Danger.js +0 -48
- package/lib/DefaultEventPluginOrder.js +0 -27
- package/lib/DisabledInputUtils.js +0 -50
- package/lib/EnterLeaveEventPlugin.js +0 -105
- package/lib/EventConstants.js +0 -97
- package/lib/EventPluginHub.js +0 -251
- package/lib/EventPluginRegistry.js +0 -247
- package/lib/EventPluginUtils.js +0 -229
- package/lib/EventPropagators.js +0 -137
- package/lib/FallbackCompositionState.js +0 -95
- package/lib/HTMLDOMPropertyConfig.js +0 -209
- package/lib/LinkedValueUtils.js +0 -136
- package/lib/NativeMethodsMixin.js +0 -167
- package/lib/ReactBrowserEventEmitter.js +0 -317
- package/lib/ReactChildReconciler.js +0 -154
- package/lib/ReactChildrenMutationWarningHook.js +0 -54
- package/lib/ReactComponentBrowserEnvironment.js +0 -30
- package/lib/ReactComponentEnvironment.js +0 -45
- package/lib/ReactComponentTreeTestUtils.js +0 -87
- package/lib/ReactCompositeComponent.js +0 -920
- package/lib/ReactDOM.js +0 -110
- package/lib/ReactDOMButton.js +0 -24
- package/lib/ReactDOMComponent.js +0 -1005
- package/lib/ReactDOMComponentTree.js +0 -188
- package/lib/ReactDOMContainerInfo.js +0 -33
- package/lib/ReactDOMEmptyComponent.js +0 -60
- package/lib/ReactDOMFiber.js +0 -76
- package/lib/ReactDOMIDOperations.js +0 -34
- package/lib/ReactDOMInput.js +0 -269
- package/lib/ReactDOMNullInputValuePropHook.js +0 -43
- package/lib/ReactDOMOption.js +0 -123
- package/lib/ReactDOMSelect.js +0 -201
- package/lib/ReactDOMSelection.js +0 -212
- package/lib/ReactDOMServer.js +0 -26
- package/lib/ReactDOMTextComponent.js +0 -164
- package/lib/ReactDOMTextarea.js +0 -155
- package/lib/ReactDOMTreeTraversal.js +0 -136
- package/lib/ReactDOMUnknownPropertyHook.js +0 -112
- package/lib/ReactDebugTool.js +0 -307
- package/lib/ReactDefaultBatchingStrategy.js +0 -68
- package/lib/ReactDefaultInjection.js +0 -84
- package/lib/ReactEmptyComponent.js +0 -30
- package/lib/ReactErrorUtils.js +0 -76
- package/lib/ReactEventEmitterMixin.js +0 -33
- package/lib/ReactEventListener.js +0 -157
- package/lib/ReactFeatureFlags.js +0 -22
- package/lib/ReactHostComponent.js +0 -76
- package/lib/ReactHostOperationHistoryHook.js +0 -37
- package/lib/ReactInjection.js +0 -36
- package/lib/ReactInputSelection.js +0 -124
- package/lib/ReactInstanceHandles.js +0 -302
- package/lib/ReactInstanceMap.js +0 -48
- package/lib/ReactInstrumentation.js +0 -21
- package/lib/ReactInvalidSetStateWarningHook.js +0 -36
- package/lib/ReactMarkupChecksum.js +0 -50
- package/lib/ReactMount.js +0 -534
- package/lib/ReactMultiChild.js +0 -451
- package/lib/ReactMultiChildUpdateTypes.js +0 -32
- package/lib/ReactNative.js +0 -71
- package/lib/ReactNativeAttributePayload.js +0 -371
- package/lib/ReactNativeBaseComponent.js +0 -198
- package/lib/ReactNativeBridgeEventPlugin.js +0 -60
- package/lib/ReactNativeComponentEnvironment.js +0 -31
- package/lib/ReactNativeComponentTree.js +0 -68
- package/lib/ReactNativeContainerInfo.js +0 -21
- package/lib/ReactNativeDOMIDOperations.js +0 -79
- package/lib/ReactNativeDefaultInjection.js +0 -101
- package/lib/ReactNativeEventEmitter.js +0 -191
- package/lib/ReactNativeEventPluginOrder.js +0 -16
- package/lib/ReactNativeGlobalResponderHandler.js +0 -25
- package/lib/ReactNativeMount.js +0 -193
- package/lib/ReactNativePropRegistry.js +0 -52
- package/lib/ReactNativeReconcileTransaction.js +0 -116
- package/lib/ReactNativeTagHandles.js +0 -56
- package/lib/ReactNativeTextComponent.js +0 -71
- package/lib/ReactNativeTreeTraversal.js +0 -127
- package/lib/ReactNodeTypes.js +0 -40
- package/lib/ReactNoop.js +0 -173
- package/lib/ReactOwner.js +0 -94
- package/lib/ReactPerf.js +0 -494
- package/lib/ReactReconcileTransaction.js +0 -178
- package/lib/ReactReconciler.js +0 -168
- package/lib/ReactRef.js +0 -80
- package/lib/ReactServerBatchingStrategy.js +0 -22
- package/lib/ReactServerRendering.js +0 -90
- package/lib/ReactServerRenderingTransaction.js +0 -90
- package/lib/ReactServerUpdateQueue.js +0 -141
- package/lib/ReactSimpleEmptyComponent.js +0 -37
- package/lib/ReactTestMount.js +0 -126
- package/lib/ReactTestReconcileTransaction.js +0 -108
- package/lib/ReactTestRenderer.js +0 -144
- package/lib/ReactTestUtils.js +0 -518
- package/lib/ReactUpdateQueue.js +0 -226
- package/lib/ReactUpdates.js +0 -251
- package/lib/ResponderEventPlugin.js +0 -510
- package/lib/ResponderSyntheticEvent.js +0 -39
- package/lib/ResponderTouchHistoryStore.js +0 -184
- package/lib/SVGDOMPropertyConfig.js +0 -302
- package/lib/SelectEventPlugin.js +0 -196
- package/lib/SimpleEventPlugin.js +0 -635
- package/lib/SyntheticAnimationEvent.js +0 -39
- package/lib/SyntheticClipboardEvent.js +0 -38
- package/lib/SyntheticCompositionEvent.js +0 -36
- package/lib/SyntheticDragEvent.js +0 -36
- package/lib/SyntheticEvent.js +0 -267
- package/lib/SyntheticFocusEvent.js +0 -36
- package/lib/SyntheticInputEvent.js +0 -37
- package/lib/SyntheticKeyboardEvent.js +0 -84
- package/lib/SyntheticMouseEvent.js +0 -72
- package/lib/SyntheticTouchEvent.js +0 -45
- package/lib/SyntheticTransitionEvent.js +0 -39
- package/lib/SyntheticUIEvent.js +0 -59
- package/lib/SyntheticWheelEvent.js +0 -54
- package/lib/TapEventPlugin.js +0 -110
- package/lib/TouchHistoryMath.js +0 -99
- package/lib/Transaction.js +0 -233
- package/lib/ViewportMetrics.js +0 -27
- package/lib/accumulate.js +0 -46
- package/lib/accumulateInto.js +0 -58
- package/lib/adler32.js +0 -44
- package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
- package/lib/createReactNativeComponentClass.js +0 -42
- package/lib/dangerousStyleValue.js +0 -79
- package/lib/escapeTextContentForBrowser.js +0 -123
- package/lib/findDOMNode.js +0 -60
- package/lib/findNodeHandle.js +0 -91
- package/lib/forEachAccumulated.js +0 -31
- package/lib/getEventCharCode.js +0 -50
- package/lib/getEventKey.js +0 -102
- package/lib/getEventModifierState.js +0 -43
- package/lib/getEventTarget.js +0 -35
- package/lib/getHostComponentFromComposite.js +0 -30
- package/lib/getNodeForCharacterOffset.js +0 -74
- package/lib/getTestDocument.js +0 -21
- package/lib/getTextContentAccessor.js +0 -33
- package/lib/getVendorPrefixedEventName.js +0 -101
- package/lib/instantiateReactComponent.js +0 -119
- package/lib/isEventSupported.js +0 -60
- package/lib/isTextInputElement.js +0 -51
- package/lib/quoteAttributeValueForBrowser.js +0 -26
- package/lib/reactComponentExpect.js +0 -217
- package/lib/setInnerHTML.js +0 -98
- package/lib/setTextContent.js +0 -48
- package/lib/shouldUpdateReactComponent.js +0 -42
- package/lib/validateDOMNesting.js +0 -369
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2013-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 ReactDOMNullInputValuePropHook
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var ReactComponentTreeHook = require('./ReactComponentTreeHook');
|
|
15
|
-
|
|
16
|
-
var warning = require('fbjs/lib/warning');
|
|
17
|
-
|
|
18
|
-
var didWarnValueNull = false;
|
|
19
|
-
|
|
20
|
-
function handleElement(debugID, element) {
|
|
21
|
-
if (element == null) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (element.type !== 'input' && element.type !== 'textarea' && element.type !== 'select') {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (element.props != null && element.props.value === null && !didWarnValueNull) {
|
|
28
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', element.type, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
|
|
29
|
-
|
|
30
|
-
didWarnValueNull = true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var ReactDOMNullInputValuePropHook = {
|
|
35
|
-
onBeforeMountComponent: function (debugID, element) {
|
|
36
|
-
handleElement(debugID, element);
|
|
37
|
-
},
|
|
38
|
-
onBeforeUpdateComponent: function (debugID, element) {
|
|
39
|
-
handleElement(debugID, element);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
module.exports = ReactDOMNullInputValuePropHook;
|
package/lib/ReactDOMOption.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2013-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 ReactDOMOption
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var _assign = require('object-assign');
|
|
15
|
-
|
|
16
|
-
var ReactChildren = require('./ReactChildren');
|
|
17
|
-
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
18
|
-
var ReactDOMSelect = require('./ReactDOMSelect');
|
|
19
|
-
|
|
20
|
-
var warning = require('fbjs/lib/warning');
|
|
21
|
-
var didWarnInvalidOptionChildren = false;
|
|
22
|
-
|
|
23
|
-
function flattenChildren(children) {
|
|
24
|
-
var content = '';
|
|
25
|
-
|
|
26
|
-
// Flatten children and warn if they aren't strings or numbers;
|
|
27
|
-
// invalid types are ignored.
|
|
28
|
-
ReactChildren.forEach(children, function (child) {
|
|
29
|
-
if (child == null) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (typeof child === 'string' || typeof child === 'number') {
|
|
33
|
-
content += child;
|
|
34
|
-
} else if (!didWarnInvalidOptionChildren) {
|
|
35
|
-
didWarnInvalidOptionChildren = true;
|
|
36
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Only strings and numbers are supported as <option> children.') : void 0;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return content;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Implements an <option> host component that warns when `selected` is set.
|
|
45
|
-
*/
|
|
46
|
-
var ReactDOMOption = {
|
|
47
|
-
mountWrapper: function (inst, props, hostParent) {
|
|
48
|
-
// TODO (yungsters): Remove support for `selected` in <option>.
|
|
49
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
50
|
-
process.env.NODE_ENV !== 'production' ? warning(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.') : void 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Look up whether this option is 'selected'
|
|
54
|
-
var selectValue = null;
|
|
55
|
-
if (hostParent != null) {
|
|
56
|
-
var selectParent = hostParent;
|
|
57
|
-
|
|
58
|
-
if (selectParent._tag === 'optgroup') {
|
|
59
|
-
selectParent = selectParent._hostParent;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (selectParent != null && selectParent._tag === 'select') {
|
|
63
|
-
selectValue = ReactDOMSelect.getSelectValueContext(selectParent);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// If the value is null (e.g., no specified value or after initial mount)
|
|
68
|
-
// or missing (e.g., for <datalist>), we don't change props.selected
|
|
69
|
-
var selected = null;
|
|
70
|
-
if (selectValue != null) {
|
|
71
|
-
var value;
|
|
72
|
-
if (props.value != null) {
|
|
73
|
-
value = props.value + '';
|
|
74
|
-
} else {
|
|
75
|
-
value = flattenChildren(props.children);
|
|
76
|
-
}
|
|
77
|
-
selected = false;
|
|
78
|
-
if (Array.isArray(selectValue)) {
|
|
79
|
-
// multiple
|
|
80
|
-
for (var i = 0; i < selectValue.length; i++) {
|
|
81
|
-
if ('' + selectValue[i] === value) {
|
|
82
|
-
selected = true;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
selected = '' + selectValue === value;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
inst._wrapperState = { selected: selected };
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
postMountWrapper: function (inst) {
|
|
95
|
-
// value="" should make a value attribute (#6219)
|
|
96
|
-
var props = inst._currentElement.props;
|
|
97
|
-
if (props.value != null) {
|
|
98
|
-
var node = ReactDOMComponentTree.getNodeFromInstance(inst);
|
|
99
|
-
node.setAttribute('value', props.value);
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
getHostProps: function (inst, props) {
|
|
104
|
-
var hostProps = _assign({ selected: undefined, children: undefined }, props);
|
|
105
|
-
|
|
106
|
-
// Read state only from initial mount because <select> updates value
|
|
107
|
-
// manually; we need the initial state only for server rendering
|
|
108
|
-
if (inst._wrapperState.selected != null) {
|
|
109
|
-
hostProps.selected = inst._wrapperState.selected;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
var content = flattenChildren(props.children);
|
|
113
|
-
|
|
114
|
-
if (content) {
|
|
115
|
-
hostProps.children = content;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return hostProps;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
module.exports = ReactDOMOption;
|
package/lib/ReactDOMSelect.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2013-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 ReactDOMSelect
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var _assign = require('object-assign');
|
|
15
|
-
|
|
16
|
-
var DisabledInputUtils = require('./DisabledInputUtils');
|
|
17
|
-
var LinkedValueUtils = require('./LinkedValueUtils');
|
|
18
|
-
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
19
|
-
var ReactUpdates = require('./ReactUpdates');
|
|
20
|
-
|
|
21
|
-
var warning = require('fbjs/lib/warning');
|
|
22
|
-
|
|
23
|
-
var didWarnValueLink = false;
|
|
24
|
-
var didWarnValueDefaultValue = false;
|
|
25
|
-
|
|
26
|
-
function updateOptionsIfPendingUpdateAndMounted() {
|
|
27
|
-
if (this._rootNodeID && this._wrapperState.pendingUpdate) {
|
|
28
|
-
this._wrapperState.pendingUpdate = false;
|
|
29
|
-
|
|
30
|
-
var props = this._currentElement.props;
|
|
31
|
-
var value = LinkedValueUtils.getValue(props);
|
|
32
|
-
|
|
33
|
-
if (value != null) {
|
|
34
|
-
updateOptions(this, Boolean(props.multiple), value);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function getDeclarationErrorAddendum(owner) {
|
|
40
|
-
if (owner) {
|
|
41
|
-
var name = owner.getName();
|
|
42
|
-
if (name) {
|
|
43
|
-
return ' Check the render method of `' + name + '`.';
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return '';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var valuePropNames = ['value', 'defaultValue'];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Validation function for `value` and `defaultValue`.
|
|
53
|
-
* @private
|
|
54
|
-
*/
|
|
55
|
-
function checkSelectPropTypes(inst, props) {
|
|
56
|
-
var owner = inst._currentElement._owner;
|
|
57
|
-
LinkedValueUtils.checkPropTypes('select', props, owner);
|
|
58
|
-
|
|
59
|
-
if (props.valueLink !== undefined && !didWarnValueLink) {
|
|
60
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `select` is deprecated; set `value` and `onChange` instead.') : void 0;
|
|
61
|
-
didWarnValueLink = true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
for (var i = 0; i < valuePropNames.length; i++) {
|
|
65
|
-
var propName = valuePropNames[i];
|
|
66
|
-
if (props[propName] == null) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
var isArray = Array.isArray(props[propName]);
|
|
70
|
-
if (props.multiple && !isArray) {
|
|
71
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
|
|
72
|
-
} else if (!props.multiple && isArray) {
|
|
73
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @param {ReactDOMComponent} inst
|
|
80
|
-
* @param {boolean} multiple
|
|
81
|
-
* @param {*} propValue A stringable (with `multiple`, a list of stringables).
|
|
82
|
-
* @private
|
|
83
|
-
*/
|
|
84
|
-
function updateOptions(inst, multiple, propValue) {
|
|
85
|
-
var selectedValue, i;
|
|
86
|
-
var options = ReactDOMComponentTree.getNodeFromInstance(inst).options;
|
|
87
|
-
|
|
88
|
-
if (multiple) {
|
|
89
|
-
selectedValue = {};
|
|
90
|
-
for (i = 0; i < propValue.length; i++) {
|
|
91
|
-
selectedValue['' + propValue[i]] = true;
|
|
92
|
-
}
|
|
93
|
-
for (i = 0; i < options.length; i++) {
|
|
94
|
-
var selected = selectedValue.hasOwnProperty(options[i].value);
|
|
95
|
-
if (options[i].selected !== selected) {
|
|
96
|
-
options[i].selected = selected;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
// Do not set `select.value` as exact behavior isn't consistent across all
|
|
101
|
-
// browsers for all cases.
|
|
102
|
-
selectedValue = '' + propValue;
|
|
103
|
-
for (i = 0; i < options.length; i++) {
|
|
104
|
-
if (options[i].value === selectedValue) {
|
|
105
|
-
options[i].selected = true;
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (options.length) {
|
|
110
|
-
options[0].selected = true;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Implements a <select> host component that allows optionally setting the
|
|
117
|
-
* props `value` and `defaultValue`. If `multiple` is false, the prop must be a
|
|
118
|
-
* stringable. If `multiple` is true, the prop must be an array of stringables.
|
|
119
|
-
*
|
|
120
|
-
* If `value` is not supplied (or null/undefined), user actions that change the
|
|
121
|
-
* selected option will trigger updates to the rendered options.
|
|
122
|
-
*
|
|
123
|
-
* If it is supplied (and not null/undefined), the rendered options will not
|
|
124
|
-
* update in response to user actions. Instead, the `value` prop must change in
|
|
125
|
-
* order for the rendered options to update.
|
|
126
|
-
*
|
|
127
|
-
* If `defaultValue` is provided, any options with the supplied values will be
|
|
128
|
-
* selected.
|
|
129
|
-
*/
|
|
130
|
-
var ReactDOMSelect = {
|
|
131
|
-
getHostProps: function (inst, props) {
|
|
132
|
-
return _assign({}, DisabledInputUtils.getHostProps(inst, props), {
|
|
133
|
-
onChange: inst._wrapperState.onChange,
|
|
134
|
-
value: undefined
|
|
135
|
-
});
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
mountWrapper: function (inst, props) {
|
|
139
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
140
|
-
checkSelectPropTypes(inst, props);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
var value = LinkedValueUtils.getValue(props);
|
|
144
|
-
inst._wrapperState = {
|
|
145
|
-
pendingUpdate: false,
|
|
146
|
-
initialValue: value != null ? value : props.defaultValue,
|
|
147
|
-
listeners: null,
|
|
148
|
-
onChange: _handleChange.bind(inst),
|
|
149
|
-
wasMultiple: Boolean(props.multiple)
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
|
|
153
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Select 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 select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components') : void 0;
|
|
154
|
-
didWarnValueDefaultValue = true;
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
getSelectValueContext: function (inst) {
|
|
159
|
-
// ReactDOMOption looks at this initial value so the initial generated
|
|
160
|
-
// markup has correct `selected` attributes
|
|
161
|
-
return inst._wrapperState.initialValue;
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
postUpdateWrapper: function (inst) {
|
|
165
|
-
var props = inst._currentElement.props;
|
|
166
|
-
|
|
167
|
-
// After the initial mount, we control selected-ness manually so don't pass
|
|
168
|
-
// this value down
|
|
169
|
-
inst._wrapperState.initialValue = undefined;
|
|
170
|
-
|
|
171
|
-
var wasMultiple = inst._wrapperState.wasMultiple;
|
|
172
|
-
inst._wrapperState.wasMultiple = Boolean(props.multiple);
|
|
173
|
-
|
|
174
|
-
var value = LinkedValueUtils.getValue(props);
|
|
175
|
-
if (value != null) {
|
|
176
|
-
inst._wrapperState.pendingUpdate = false;
|
|
177
|
-
updateOptions(inst, Boolean(props.multiple), value);
|
|
178
|
-
} else if (wasMultiple !== Boolean(props.multiple)) {
|
|
179
|
-
// For simplicity, reapply `defaultValue` if `multiple` is toggled.
|
|
180
|
-
if (props.defaultValue != null) {
|
|
181
|
-
updateOptions(inst, Boolean(props.multiple), props.defaultValue);
|
|
182
|
-
} else {
|
|
183
|
-
// Revert the select back to its default unselected state.
|
|
184
|
-
updateOptions(inst, Boolean(props.multiple), props.multiple ? [] : '');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
function _handleChange(event) {
|
|
191
|
-
var props = this._currentElement.props;
|
|
192
|
-
var returnValue = LinkedValueUtils.executeOnChange(props, event);
|
|
193
|
-
|
|
194
|
-
if (this._rootNodeID) {
|
|
195
|
-
this._wrapperState.pendingUpdate = true;
|
|
196
|
-
}
|
|
197
|
-
ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
|
|
198
|
-
return returnValue;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
module.exports = ReactDOMSelect;
|
package/lib/ReactDOMSelection.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2013-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 ReactDOMSelection
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
15
|
-
|
|
16
|
-
var getNodeForCharacterOffset = require('./getNodeForCharacterOffset');
|
|
17
|
-
var getTextContentAccessor = require('./getTextContentAccessor');
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* While `isCollapsed` is available on the Selection object and `collapsed`
|
|
21
|
-
* is available on the Range object, IE11 sometimes gets them wrong.
|
|
22
|
-
* If the anchor/focus nodes and offsets are the same, the range is collapsed.
|
|
23
|
-
*/
|
|
24
|
-
function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) {
|
|
25
|
-
return anchorNode === focusNode && anchorOffset === focusOffset;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get the appropriate anchor and focus node/offset pairs for IE.
|
|
30
|
-
*
|
|
31
|
-
* The catch here is that IE's selection API doesn't provide information
|
|
32
|
-
* about whether the selection is forward or backward, so we have to
|
|
33
|
-
* behave as though it's always forward.
|
|
34
|
-
*
|
|
35
|
-
* IE text differs from modern selection in that it behaves as though
|
|
36
|
-
* block elements end with a new line. This means character offsets will
|
|
37
|
-
* differ between the two APIs.
|
|
38
|
-
*
|
|
39
|
-
* @param {DOMElement} node
|
|
40
|
-
* @return {object}
|
|
41
|
-
*/
|
|
42
|
-
function getIEOffsets(node) {
|
|
43
|
-
var selection = document.selection;
|
|
44
|
-
var selectedRange = selection.createRange();
|
|
45
|
-
var selectedLength = selectedRange.text.length;
|
|
46
|
-
|
|
47
|
-
// Duplicate selection so we can move range without breaking user selection.
|
|
48
|
-
var fromStart = selectedRange.duplicate();
|
|
49
|
-
fromStart.moveToElementText(node);
|
|
50
|
-
fromStart.setEndPoint('EndToStart', selectedRange);
|
|
51
|
-
|
|
52
|
-
var startOffset = fromStart.text.length;
|
|
53
|
-
var endOffset = startOffset + selectedLength;
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
start: startOffset,
|
|
57
|
-
end: endOffset
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @param {DOMElement} node
|
|
63
|
-
* @return {?object}
|
|
64
|
-
*/
|
|
65
|
-
function getModernOffsets(node) {
|
|
66
|
-
var selection = window.getSelection && window.getSelection();
|
|
67
|
-
|
|
68
|
-
if (!selection || selection.rangeCount === 0) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
var anchorNode = selection.anchorNode;
|
|
73
|
-
var anchorOffset = selection.anchorOffset;
|
|
74
|
-
var focusNode = selection.focusNode;
|
|
75
|
-
var focusOffset = selection.focusOffset;
|
|
76
|
-
|
|
77
|
-
var currentRange = selection.getRangeAt(0);
|
|
78
|
-
|
|
79
|
-
// In Firefox, range.startContainer and range.endContainer can be "anonymous
|
|
80
|
-
// divs", e.g. the up/down buttons on an <input type="number">. Anonymous
|
|
81
|
-
// divs do not seem to expose properties, triggering a "Permission denied
|
|
82
|
-
// error" if any of its properties are accessed. The only seemingly possible
|
|
83
|
-
// way to avoid erroring is to access a property that typically works for
|
|
84
|
-
// non-anonymous divs and catch any error that may otherwise arise. See
|
|
85
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=208427
|
|
86
|
-
try {
|
|
87
|
-
/* eslint-disable no-unused-expressions */
|
|
88
|
-
currentRange.startContainer.nodeType;
|
|
89
|
-
currentRange.endContainer.nodeType;
|
|
90
|
-
/* eslint-enable no-unused-expressions */
|
|
91
|
-
} catch (e) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// If the node and offset values are the same, the selection is collapsed.
|
|
96
|
-
// `Selection.isCollapsed` is available natively, but IE sometimes gets
|
|
97
|
-
// this value wrong.
|
|
98
|
-
var isSelectionCollapsed = isCollapsed(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
|
|
99
|
-
|
|
100
|
-
var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
|
|
101
|
-
|
|
102
|
-
var tempRange = currentRange.cloneRange();
|
|
103
|
-
tempRange.selectNodeContents(node);
|
|
104
|
-
tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
|
|
105
|
-
|
|
106
|
-
var isTempRangeCollapsed = isCollapsed(tempRange.startContainer, tempRange.startOffset, tempRange.endContainer, tempRange.endOffset);
|
|
107
|
-
|
|
108
|
-
var start = isTempRangeCollapsed ? 0 : tempRange.toString().length;
|
|
109
|
-
var end = start + rangeLength;
|
|
110
|
-
|
|
111
|
-
// Detect whether the selection is backward.
|
|
112
|
-
var detectionRange = document.createRange();
|
|
113
|
-
detectionRange.setStart(anchorNode, anchorOffset);
|
|
114
|
-
detectionRange.setEnd(focusNode, focusOffset);
|
|
115
|
-
var isBackward = detectionRange.collapsed;
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
start: isBackward ? end : start,
|
|
119
|
-
end: isBackward ? start : end
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @param {DOMElement|DOMTextNode} node
|
|
125
|
-
* @param {object} offsets
|
|
126
|
-
*/
|
|
127
|
-
function setIEOffsets(node, offsets) {
|
|
128
|
-
var range = document.selection.createRange().duplicate();
|
|
129
|
-
var start, end;
|
|
130
|
-
|
|
131
|
-
if (offsets.end === undefined) {
|
|
132
|
-
start = offsets.start;
|
|
133
|
-
end = start;
|
|
134
|
-
} else if (offsets.start > offsets.end) {
|
|
135
|
-
start = offsets.end;
|
|
136
|
-
end = offsets.start;
|
|
137
|
-
} else {
|
|
138
|
-
start = offsets.start;
|
|
139
|
-
end = offsets.end;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
range.moveToElementText(node);
|
|
143
|
-
range.moveStart('character', start);
|
|
144
|
-
range.setEndPoint('EndToStart', range);
|
|
145
|
-
range.moveEnd('character', end - start);
|
|
146
|
-
range.select();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* In modern non-IE browsers, we can support both forward and backward
|
|
151
|
-
* selections.
|
|
152
|
-
*
|
|
153
|
-
* Note: IE10+ supports the Selection object, but it does not support
|
|
154
|
-
* the `extend` method, which means that even in modern IE, it's not possible
|
|
155
|
-
* to programmatically create a backward selection. Thus, for all IE
|
|
156
|
-
* versions, we use the old IE API to create our selections.
|
|
157
|
-
*
|
|
158
|
-
* @param {DOMElement|DOMTextNode} node
|
|
159
|
-
* @param {object} offsets
|
|
160
|
-
*/
|
|
161
|
-
function setModernOffsets(node, offsets) {
|
|
162
|
-
if (!window.getSelection) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
var selection = window.getSelection();
|
|
167
|
-
var length = node[getTextContentAccessor()].length;
|
|
168
|
-
var start = Math.min(offsets.start, length);
|
|
169
|
-
var end = offsets.end === undefined ? start : Math.min(offsets.end, length);
|
|
170
|
-
|
|
171
|
-
// IE 11 uses modern selection, but doesn't support the extend method.
|
|
172
|
-
// Flip backward selections, so we can set with a single range.
|
|
173
|
-
if (!selection.extend && start > end) {
|
|
174
|
-
var temp = end;
|
|
175
|
-
end = start;
|
|
176
|
-
start = temp;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
var startMarker = getNodeForCharacterOffset(node, start);
|
|
180
|
-
var endMarker = getNodeForCharacterOffset(node, end);
|
|
181
|
-
|
|
182
|
-
if (startMarker && endMarker) {
|
|
183
|
-
var range = document.createRange();
|
|
184
|
-
range.setStart(startMarker.node, startMarker.offset);
|
|
185
|
-
selection.removeAllRanges();
|
|
186
|
-
|
|
187
|
-
if (start > end) {
|
|
188
|
-
selection.addRange(range);
|
|
189
|
-
selection.extend(endMarker.node, endMarker.offset);
|
|
190
|
-
} else {
|
|
191
|
-
range.setEnd(endMarker.node, endMarker.offset);
|
|
192
|
-
selection.addRange(range);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
var useIEOffsets = ExecutionEnvironment.canUseDOM && 'selection' in document && !('getSelection' in window);
|
|
198
|
-
|
|
199
|
-
var ReactDOMSelection = {
|
|
200
|
-
/**
|
|
201
|
-
* @param {DOMElement} node
|
|
202
|
-
*/
|
|
203
|
-
getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* @param {DOMElement|DOMTextNode} node
|
|
207
|
-
* @param {object} offsets
|
|
208
|
-
*/
|
|
209
|
-
setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
module.exports = ReactDOMSelection;
|