react 0.14.10 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/react-with-addons.js +4900 -4627
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4556 -4059
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +49 -19
- package/lib/CallbackQueue.js +16 -4
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +91 -61
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +42 -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 +4 -4
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +6 -7
- package/lib/MetaMatchers.js +2 -2
- package/lib/OrderedMap.js +17 -16
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +50 -20
- package/lib/ReactBrowserEventEmitter.js +19 -26
- package/lib/ReactCSSTransitionGroup.js +4 -5
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +44 -92
- package/lib/ReactComponent.js +9 -10
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +166 -74
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +186 -250
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -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 +73 -23
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +14 -12
- package/lib/ReactDOMSelect.js +43 -19
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +87 -45
- package/lib/ReactDOMTextarea.js +39 -11
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugInstanceMap.js +102 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +4 -3
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +105 -26
- package/lib/ReactDefaultPerfAnalysis.js +23 -15
- package/lib/ReactElement.js +63 -23
- package/lib/ReactElementValidator.js +9 -9
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +23 -77
- 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/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +88 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -5
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +7 -6
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +5 -4
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +20 -9
- 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 +11 -29
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +47 -28
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +4 -3
- package/lib/ReactUMDEntry.js +26 -0
- package/lib/ReactUpdateQueue.js +24 -66
- package/lib/ReactUpdates.js +29 -11
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -21
- package/lib/ReactWithAddonsUMDEntry.js +26 -0
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +267 -94
- 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 +102 -21
- 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 +7 -4
- 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 +12 -13
- 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 +5 -4
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +6 -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 +16 -15
- package/lib/validateDOMNesting.js +18 -13
- package/package.json +23 -32
- package/addons.js +0 -13
- package/cjs/react-jsx-dev-runtime.development.js +0 -861
- package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
- package/cjs/react-jsx-runtime.development.js +0 -883
- package/cjs/react-jsx-runtime.production.min.js +0 -10
- package/jsx-dev-runtime.js +0 -7
- package/jsx-runtime.js +0 -7
- package/lib/Object.assign.js +0 -47
- package/lib/React.native.js +0 -5
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactIsomorphic.js +0 -74
- 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/ReactElement.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014-
|
|
2
|
+
* Copyright 2014-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,9 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
14
16
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
15
17
|
|
|
16
|
-
var
|
|
18
|
+
var warning = require('fbjs/lib/warning');
|
|
17
19
|
var canDefineProperty = require('./canDefineProperty');
|
|
18
20
|
|
|
19
21
|
// The Symbol used to tag the ReactElement type. If there is no native Symbol
|
|
@@ -27,9 +29,13 @@ var RESERVED_PROPS = {
|
|
|
27
29
|
__source: true
|
|
28
30
|
};
|
|
29
31
|
|
|
32
|
+
var specialPropKeyWarningShown, specialPropRefWarningShown;
|
|
33
|
+
|
|
30
34
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
35
|
+
* Factory method to create a new React element. This no longer adheres to
|
|
36
|
+
* the class pattern, so do not use new to call it. Also, no instanceof check
|
|
37
|
+
* will work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
38
|
+
* if something is a React Element.
|
|
33
39
|
*
|
|
34
40
|
* @param {*} type
|
|
35
41
|
* @param {*} key
|
|
@@ -98,8 +104,10 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
98
104
|
element._self = self;
|
|
99
105
|
element._source = source;
|
|
100
106
|
}
|
|
101
|
-
Object.freeze
|
|
102
|
-
|
|
107
|
+
if (Object.freeze) {
|
|
108
|
+
Object.freeze(element.props);
|
|
109
|
+
Object.freeze(element);
|
|
110
|
+
}
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
return element;
|
|
@@ -117,8 +125,13 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
117
125
|
var source = null;
|
|
118
126
|
|
|
119
127
|
if (config != null) {
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
129
|
+
ref = !config.hasOwnProperty('ref') || Object.getOwnPropertyDescriptor(config, 'ref').get ? null : config.ref;
|
|
130
|
+
key = !config.hasOwnProperty('key') || Object.getOwnPropertyDescriptor(config, 'key').get ? null : '' + config.key;
|
|
131
|
+
} else {
|
|
132
|
+
ref = config.ref === undefined ? null : config.ref;
|
|
133
|
+
key = config.key === undefined ? null : '' + config.key;
|
|
134
|
+
}
|
|
122
135
|
self = config.__self === undefined ? null : config.__self;
|
|
123
136
|
source = config.__source === undefined ? null : config.__source;
|
|
124
137
|
// Remaining properties are added to a new props object
|
|
@@ -146,12 +159,41 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
146
159
|
if (type && type.defaultProps) {
|
|
147
160
|
var defaultProps = type.defaultProps;
|
|
148
161
|
for (propName in defaultProps) {
|
|
149
|
-
if (
|
|
162
|
+
if (props[propName] === undefined) {
|
|
150
163
|
props[propName] = defaultProps[propName];
|
|
151
164
|
}
|
|
152
165
|
}
|
|
153
166
|
}
|
|
154
|
-
|
|
167
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
168
|
+
// Create dummy `key` and `ref` property to `props` to warn users
|
|
169
|
+
// against its use
|
|
170
|
+
if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
|
|
171
|
+
if (!props.hasOwnProperty('key')) {
|
|
172
|
+
Object.defineProperty(props, 'key', {
|
|
173
|
+
get: function () {
|
|
174
|
+
if (!specialPropKeyWarningShown) {
|
|
175
|
+
specialPropKeyWarningShown = true;
|
|
176
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', typeof type === 'function' && 'displayName' in type ? type.displayName : 'Element') : void 0;
|
|
177
|
+
}
|
|
178
|
+
return undefined;
|
|
179
|
+
},
|
|
180
|
+
configurable: true
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (!props.hasOwnProperty('ref')) {
|
|
184
|
+
Object.defineProperty(props, 'ref', {
|
|
185
|
+
get: function () {
|
|
186
|
+
if (!specialPropRefWarningShown) {
|
|
187
|
+
specialPropRefWarningShown = true;
|
|
188
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', typeof type === 'function' && 'displayName' in type ? type.displayName : 'Element') : void 0;
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
},
|
|
192
|
+
configurable: true
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
155
197
|
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
156
198
|
};
|
|
157
199
|
|
|
@@ -172,22 +214,11 @@ ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
|
|
|
172
214
|
return newElement;
|
|
173
215
|
};
|
|
174
216
|
|
|
175
|
-
ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
|
|
176
|
-
var newElement = ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, newProps);
|
|
177
|
-
|
|
178
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
179
|
-
// If the key on the original is valid, then the clone is valid
|
|
180
|
-
newElement._store.validated = oldElement._store.validated;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return newElement;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
217
|
ReactElement.cloneElement = function (element, config, children) {
|
|
187
218
|
var propName;
|
|
188
219
|
|
|
189
220
|
// Original props are copied
|
|
190
|
-
var props =
|
|
221
|
+
var props = _assign({}, element.props);
|
|
191
222
|
|
|
192
223
|
// Reserved names are extracted
|
|
193
224
|
var key = element.key;
|
|
@@ -212,9 +243,18 @@ ReactElement.cloneElement = function (element, config, children) {
|
|
|
212
243
|
key = '' + config.key;
|
|
213
244
|
}
|
|
214
245
|
// Remaining properties override existing props
|
|
246
|
+
var defaultProps;
|
|
247
|
+
if (element.type && element.type.defaultProps) {
|
|
248
|
+
defaultProps = element.type.defaultProps;
|
|
249
|
+
}
|
|
215
250
|
for (propName in config) {
|
|
216
251
|
if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
217
|
-
|
|
252
|
+
if (config[propName] === undefined && defaultProps !== undefined) {
|
|
253
|
+
// Resolve default props
|
|
254
|
+
props[propName] = defaultProps[propName];
|
|
255
|
+
} else {
|
|
256
|
+
props[propName] = config[propName];
|
|
257
|
+
}
|
|
218
258
|
}
|
|
219
259
|
}
|
|
220
260
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014-
|
|
2
|
+
* Copyright 2014-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
|
|
@@ -68,7 +68,7 @@ function validateExplicitKey(element, parentType) {
|
|
|
68
68
|
// we already showed the warning
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') :
|
|
71
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : void 0;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
@@ -174,19 +174,19 @@ function checkPropTypes(componentName, propTypes, props, location) {
|
|
|
174
174
|
try {
|
|
175
175
|
// This is intentionally an invariant that gets caught. It's the same
|
|
176
176
|
// behavior as without this statement except with a better message.
|
|
177
|
-
!(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) :
|
|
178
|
-
error = propTypes[propName](props, propName, componentName, location
|
|
177
|
+
!(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : void 0;
|
|
178
|
+
error = propTypes[propName](props, propName, componentName, location);
|
|
179
179
|
} catch (ex) {
|
|
180
180
|
error = ex;
|
|
181
181
|
}
|
|
182
|
-
process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) :
|
|
182
|
+
process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : void 0;
|
|
183
183
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
184
184
|
// Only monitor this failure once because there tends to be a lot of the
|
|
185
185
|
// same error.
|
|
186
186
|
loggedTypeFailures[error.message] = true;
|
|
187
187
|
|
|
188
188
|
var addendum = getDeclarationErrorAddendum();
|
|
189
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) :
|
|
189
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : void 0;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -208,7 +208,7 @@ function validatePropTypes(element) {
|
|
|
208
208
|
checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
|
|
209
209
|
}
|
|
210
210
|
if (typeof componentClass.getDefaultProps === 'function') {
|
|
211
|
-
process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') :
|
|
211
|
+
process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -218,7 +218,7 @@ var ReactElementValidator = {
|
|
|
218
218
|
var validType = typeof type === 'string' || typeof type === 'function';
|
|
219
219
|
// We warn in this case but don't throw. We expect the element creation to
|
|
220
220
|
// succeed and there will likely be errors in render.
|
|
221
|
-
process.env.NODE_ENV !== 'production' ? warning(validType, 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) :
|
|
221
|
+
process.env.NODE_ENV !== 'production' ? warning(validType, 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : void 0;
|
|
222
222
|
|
|
223
223
|
var element = ReactElement.createElement.apply(this, arguments);
|
|
224
224
|
|
|
@@ -254,7 +254,7 @@ var ReactElementValidator = {
|
|
|
254
254
|
Object.defineProperty(validatedFactory, 'type', {
|
|
255
255
|
enumerable: false,
|
|
256
256
|
get: function () {
|
|
257
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') :
|
|
257
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : void 0;
|
|
258
258
|
Object.defineProperty(this, 'type', {
|
|
259
259
|
value: type
|
|
260
260
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014-
|
|
2
|
+
* Copyright 2014-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,44 +11,19 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var ReactEmptyComponentRegistry = require('./ReactEmptyComponentRegistry');
|
|
16
|
-
var ReactReconciler = require('./ReactReconciler');
|
|
17
|
-
|
|
18
|
-
var assign = require('./Object.assign');
|
|
19
|
-
|
|
20
|
-
var placeholderElement;
|
|
14
|
+
var emptyComponentFactory;
|
|
21
15
|
|
|
22
16
|
var ReactEmptyComponentInjection = {
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
injectEmptyComponentFactory: function (factory) {
|
|
18
|
+
emptyComponentFactory = factory;
|
|
25
19
|
}
|
|
26
20
|
};
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var ReactEmptyComponent = function (instantiate) {
|
|
33
|
-
this._currentElement = null;
|
|
34
|
-
this._rootNodeID = null;
|
|
35
|
-
this._renderedComponent = instantiate(placeholderElement);
|
|
36
|
-
};
|
|
37
|
-
assign(ReactEmptyComponent.prototype, {
|
|
38
|
-
construct: function (element) {},
|
|
39
|
-
mountComponent: function (rootID, transaction, context) {
|
|
40
|
-
transaction.getReactMountReady().enqueue(registerNullComponentID, this);
|
|
41
|
-
this._rootNodeID = rootID;
|
|
42
|
-
return ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, context);
|
|
43
|
-
},
|
|
44
|
-
receiveComponent: function () {},
|
|
45
|
-
unmountComponent: function (rootID, transaction, context) {
|
|
46
|
-
ReactReconciler.unmountComponent(this._renderedComponent);
|
|
47
|
-
ReactEmptyComponentRegistry.deregisterNullComponentID(this._rootNodeID);
|
|
48
|
-
this._rootNodeID = null;
|
|
49
|
-
this._renderedComponent = null;
|
|
22
|
+
var ReactEmptyComponent = {
|
|
23
|
+
create: function (instantiate) {
|
|
24
|
+
return emptyComponentFactory(instantiate);
|
|
50
25
|
}
|
|
51
|
-
}
|
|
26
|
+
};
|
|
52
27
|
|
|
53
28
|
ReactEmptyComponent.injection = ReactEmptyComponentInjection;
|
|
54
29
|
|
package/lib/ReactErrorUtils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactErrorUtils
|
|
10
|
-
* @typechecks
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -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
|
|
@@ -23,14 +23,9 @@ var ReactEventEmitterMixin = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Streams a fired top-level event to `EventPluginHub` where plugins have the
|
|
25
25
|
* opportunity to create `ReactEvent`s to be dispatched.
|
|
26
|
-
*
|
|
27
|
-
* @param {string} topLevelType Record from `EventConstants`.
|
|
28
|
-
* @param {object} topLevelTarget The listening component root node.
|
|
29
|
-
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
30
|
-
* @param {object} nativeEvent Native environment event.
|
|
31
26
|
*/
|
|
32
|
-
handleTopLevel: function (topLevelType,
|
|
33
|
-
var events = EventPluginHub.extractEvents(topLevelType,
|
|
27
|
+
handleTopLevel: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
28
|
+
var events = EventPluginHub.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
|
|
34
29
|
runEventQueueInBatch(events);
|
|
35
30
|
}
|
|
36
31
|
};
|
|
@@ -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,40 +7,36 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactEventListener
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
15
16
|
var EventListener = require('fbjs/lib/EventListener');
|
|
16
17
|
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
17
18
|
var PooledClass = require('./PooledClass');
|
|
18
|
-
var
|
|
19
|
-
var ReactMount = require('./ReactMount');
|
|
19
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
20
20
|
var ReactUpdates = require('./ReactUpdates');
|
|
21
21
|
|
|
22
|
-
var assign = require('./Object.assign');
|
|
23
22
|
var getEventTarget = require('./getEventTarget');
|
|
24
23
|
var getUnboundedScrollPosition = require('fbjs/lib/getUnboundedScrollPosition');
|
|
25
24
|
|
|
26
|
-
var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
|
|
27
|
-
|
|
28
25
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @return {?DOMEventTarget} Parent container, or `null` if the specified node
|
|
33
|
-
* is not nested.
|
|
26
|
+
* Find the deepest React component completely containing the root of the
|
|
27
|
+
* passed-in instance (for use when entire React trees are nested within each
|
|
28
|
+
* other). If React trees are not nested, returns null.
|
|
34
29
|
*/
|
|
35
|
-
function findParent(
|
|
30
|
+
function findParent(inst) {
|
|
36
31
|
// TODO: It may be a good idea to cache this to prevent unnecessary DOM
|
|
37
32
|
// traversal, but caching is difficult to do correctly without using a
|
|
38
33
|
// mutation observer to listen for all DOM changes.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
|
|
34
|
+
while (inst._nativeParent) {
|
|
35
|
+
inst = inst._nativeParent;
|
|
36
|
+
}
|
|
37
|
+
var rootNode = ReactDOMComponentTree.getNodeFromInstance(inst);
|
|
38
|
+
var container = rootNode.parentNode;
|
|
39
|
+
return ReactDOMComponentTree.getClosestInstanceFromNode(container);
|
|
44
40
|
}
|
|
45
41
|
|
|
46
42
|
// Used to store ancestor hierarchy in top level callback
|
|
@@ -49,7 +45,7 @@ function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
|
|
|
49
45
|
this.nativeEvent = nativeEvent;
|
|
50
46
|
this.ancestors = [];
|
|
51
47
|
}
|
|
52
|
-
|
|
48
|
+
_assign(TopLevelCallbackBookKeeping.prototype, {
|
|
53
49
|
destructor: function () {
|
|
54
50
|
this.topLevelType = null;
|
|
55
51
|
this.nativeEvent = null;
|
|
@@ -59,72 +55,22 @@ assign(TopLevelCallbackBookKeeping.prototype, {
|
|
|
59
55
|
PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
|
|
60
56
|
|
|
61
57
|
function handleTopLevelImpl(bookKeeping) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) {
|
|
65
|
-
// // New browsers have a path attribute on native events
|
|
66
|
-
// handleTopLevelWithPath(bookKeeping);
|
|
67
|
-
// } else {
|
|
68
|
-
// // Legacy browsers don't have a path attribute on native events
|
|
69
|
-
// handleTopLevelWithoutPath(bookKeeping);
|
|
70
|
-
// }
|
|
71
|
-
|
|
72
|
-
void handleTopLevelWithPath; // temporarily unused
|
|
73
|
-
handleTopLevelWithoutPath(bookKeeping);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Legacy browsers don't have a path attribute on native events
|
|
77
|
-
function handleTopLevelWithoutPath(bookKeeping) {
|
|
78
|
-
var topLevelTarget = ReactMount.getFirstReactDOM(getEventTarget(bookKeeping.nativeEvent)) || window;
|
|
58
|
+
var nativeEventTarget = getEventTarget(bookKeeping.nativeEvent);
|
|
59
|
+
var targetInst = ReactDOMComponentTree.getClosestInstanceFromNode(nativeEventTarget);
|
|
79
60
|
|
|
80
61
|
// Loop through the hierarchy, in case there's any nested components.
|
|
81
62
|
// It's important that we build the array of ancestors before calling any
|
|
82
63
|
// event handlers, because event handlers can modify the DOM, leading to
|
|
83
64
|
// inconsistencies with ReactMount's node cache. See #1105.
|
|
84
|
-
var ancestor =
|
|
85
|
-
|
|
65
|
+
var ancestor = targetInst;
|
|
66
|
+
do {
|
|
86
67
|
bookKeeping.ancestors.push(ancestor);
|
|
87
|
-
ancestor = findParent(ancestor);
|
|
88
|
-
}
|
|
68
|
+
ancestor = ancestor && findParent(ancestor);
|
|
69
|
+
} while (ancestor);
|
|
89
70
|
|
|
90
71
|
for (var i = 0; i < bookKeeping.ancestors.length; i++) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// New browsers have a path attribute on native events
|
|
98
|
-
function handleTopLevelWithPath(bookKeeping) {
|
|
99
|
-
var path = bookKeeping.nativeEvent.path;
|
|
100
|
-
var currentNativeTarget = path[0];
|
|
101
|
-
var eventsFired = 0;
|
|
102
|
-
for (var i = 0; i < path.length; i++) {
|
|
103
|
-
var currentPathElement = path[i];
|
|
104
|
-
if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
|
|
105
|
-
currentNativeTarget = path[i + 1];
|
|
106
|
-
}
|
|
107
|
-
// TODO: slow
|
|
108
|
-
var reactParent = ReactMount.getFirstReactDOM(currentPathElement);
|
|
109
|
-
if (reactParent === currentPathElement) {
|
|
110
|
-
var currentPathElementID = ReactMount.getID(currentPathElement);
|
|
111
|
-
var newRootID = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElementID);
|
|
112
|
-
bookKeeping.ancestors.push(currentPathElement);
|
|
113
|
-
|
|
114
|
-
var topLevelTargetID = ReactMount.getID(currentPathElement) || '';
|
|
115
|
-
eventsFired++;
|
|
116
|
-
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, currentPathElement, topLevelTargetID, bookKeeping.nativeEvent, currentNativeTarget);
|
|
117
|
-
|
|
118
|
-
// Jump to the root of this React render tree
|
|
119
|
-
while (currentPathElementID !== newRootID) {
|
|
120
|
-
i++;
|
|
121
|
-
currentPathElement = path[i];
|
|
122
|
-
currentPathElementID = ReactMount.getID(currentPathElement);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (eventsFired === 0) {
|
|
127
|
-
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, window, '', bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
|
|
72
|
+
targetInst = bookKeeping.ancestors[i];
|
|
73
|
+
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
|
|
128
74
|
}
|
|
129
75
|
}
|
|
130
76
|
|