react 0.14.8 → 15.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/addons.js +2 -0
- package/dist/react-with-addons.js +4203 -4148
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4159 -3850
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +4 -1
- package/lib/CSSPropertyOperations.js +24 -10
- package/lib/CallbackQueue.js +13 -2
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +93 -60
- package/lib/DOMLazyTree.js +96 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +87 -53
- package/lib/Danger.js +13 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +22 -66
- package/lib/EventPluginRegistry.js +30 -9
- package/lib/EventPluginUtils.js +61 -36
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +1 -2
- package/lib/HTMLDOMPropertyConfig.js +69 -90
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +5 -6
- package/lib/MetaMatchers.js +2 -2
- package/lib/Object.assign.js +1 -1
- package/lib/OrderedMap.js +14 -14
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +1 -13
- package/lib/ReactBrowserEventEmitter.js +16 -24
- package/lib/ReactCSSTransitionGroup.js +1 -2
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +37 -86
- package/lib/ReactComponent.js +7 -8
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +160 -69
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +188 -244
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +69 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +71 -22
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +11 -10
- package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +61 -0
- package/lib/ReactDOMSelect.js +40 -17
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +84 -43
- package/lib/ReactDOMTextarea.js +36 -9
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +59 -19
- package/lib/ReactDefaultPerfAnalysis.js +17 -9
- package/lib/ReactElement.js +60 -21
- package/lib/ReactElementValidator.js +8 -8
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +20 -75
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +6 -6
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -12
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactIsomorphic.js +1 -1
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +87 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +3 -3
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +27 -3
- package/lib/ReactReconcileTransaction.js +17 -6
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +17 -35
- package/lib/ReactServerRenderingTransaction.js +8 -26
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +33 -24
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +1 -1
- package/lib/ReactUpdateQueue.js +6 -65
- package/lib/ReactUpdates.js +26 -9
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -14
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +1 -2
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +25 -66
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +57 -17
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +97 -17
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +2 -2
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +4 -2
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +2 -2
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +9 -11
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +2 -2
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +2 -2
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +5 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +8 -8
- package/lib/update.js +12 -12
- package/lib/validateDOMNesting.js +15 -11
- package/package.json +2 -2
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
|
@@ -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) :
|
|
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
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,7 +7,6 @@
|
|
|
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';
|
|
@@ -15,32 +14,28 @@
|
|
|
15
14
|
var EventListener = require('fbjs/lib/EventListener');
|
|
16
15
|
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
17
16
|
var PooledClass = require('./PooledClass');
|
|
18
|
-
var
|
|
19
|
-
var ReactMount = require('./ReactMount');
|
|
17
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
20
18
|
var ReactUpdates = require('./ReactUpdates');
|
|
21
19
|
|
|
22
20
|
var assign = require('./Object.assign');
|
|
23
21
|
var getEventTarget = require('./getEventTarget');
|
|
24
22
|
var getUnboundedScrollPosition = require('fbjs/lib/getUnboundedScrollPosition');
|
|
25
23
|
|
|
26
|
-
var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
|
|
27
|
-
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @return {?DOMEventTarget} Parent container, or `null` if the specified node
|
|
33
|
-
* is not nested.
|
|
25
|
+
* Find the deepest React component completely containing the root of the
|
|
26
|
+
* passed-in instance (for use when entire React trees are nested within each
|
|
27
|
+
* other). If React trees are not nested, returns null.
|
|
34
28
|
*/
|
|
35
|
-
function findParent(
|
|
29
|
+
function findParent(inst) {
|
|
36
30
|
// TODO: It may be a good idea to cache this to prevent unnecessary DOM
|
|
37
31
|
// traversal, but caching is difficult to do correctly without using a
|
|
38
32
|
// mutation observer to listen for all DOM changes.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
|
|
33
|
+
while (inst._nativeParent) {
|
|
34
|
+
inst = inst._nativeParent;
|
|
35
|
+
}
|
|
36
|
+
var rootNode = ReactDOMComponentTree.getNodeFromInstance(inst);
|
|
37
|
+
var container = rootNode.parentNode;
|
|
38
|
+
return ReactDOMComponentTree.getClosestInstanceFromNode(container);
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
// Used to store ancestor hierarchy in top level callback
|
|
@@ -59,72 +54,22 @@ assign(TopLevelCallbackBookKeeping.prototype, {
|
|
|
59
54
|
PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
|
|
60
55
|
|
|
61
56
|
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;
|
|
57
|
+
var nativeEventTarget = getEventTarget(bookKeeping.nativeEvent);
|
|
58
|
+
var targetInst = ReactDOMComponentTree.getClosestInstanceFromNode(nativeEventTarget);
|
|
79
59
|
|
|
80
60
|
// Loop through the hierarchy, in case there's any nested components.
|
|
81
61
|
// It's important that we build the array of ancestors before calling any
|
|
82
62
|
// event handlers, because event handlers can modify the DOM, leading to
|
|
83
63
|
// inconsistencies with ReactMount's node cache. See #1105.
|
|
84
|
-
var ancestor =
|
|
85
|
-
|
|
64
|
+
var ancestor = targetInst;
|
|
65
|
+
do {
|
|
86
66
|
bookKeeping.ancestors.push(ancestor);
|
|
87
|
-
ancestor = findParent(ancestor);
|
|
88
|
-
}
|
|
67
|
+
ancestor = ancestor && findParent(ancestor);
|
|
68
|
+
} while (ancestor);
|
|
89
69
|
|
|
90
70
|
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));
|
|
71
|
+
targetInst = bookKeeping.ancestors[i];
|
|
72
|
+
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
|
|
128
73
|
}
|
|
129
74
|
}
|
|
130
75
|
|
|
@@ -0,0 +1,21 @@
|
|
|
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 ReactFeatureFlags
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactFeatureFlags = {
|
|
15
|
+
// When true, call console.time() before and .timeEnd() after each top-level
|
|
16
|
+
// render (both initial renders and updates). Useful when looking at prod-mode
|
|
17
|
+
// timeline profiles in Chrome, for example.
|
|
18
|
+
logTopLevelRenders: false
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = ReactFeatureFlags;
|
package/lib/ReactFragment.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2015, Facebook, Inc.
|
|
2
|
+
* Copyright 2015-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
|
|
@@ -20,7 +20,7 @@ var warning = require('fbjs/lib/warning');
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* We used to allow keyed objects to serve as a collection of ReactElements,
|
|
23
|
-
* or nested sets. This allowed us a way to explicitly key a set
|
|
23
|
+
* or nested sets. This allowed us a way to explicitly key a set or fragment of
|
|
24
24
|
* components. This is now being replaced with an opaque data structure.
|
|
25
25
|
* The upgrade path is to call React.addons.createFragment({ key: value }) to
|
|
26
26
|
* create a keyed fragment. The resulting data structure is an array.
|
|
@@ -35,22 +35,22 @@ var ReactFragment = {
|
|
|
35
35
|
// of its properties.
|
|
36
36
|
create: function (object) {
|
|
37
37
|
if (typeof object !== 'object' || !object || Array.isArray(object)) {
|
|
38
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) :
|
|
38
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : void 0;
|
|
39
39
|
return object;
|
|
40
40
|
}
|
|
41
41
|
if (ReactElement.isValidElement(object)) {
|
|
42
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') :
|
|
42
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') : void 0;
|
|
43
43
|
return object;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
!(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM ' + 'elements are not valid children of React components.') : invariant(false) :
|
|
46
|
+
!(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM ' + 'elements are not valid children of React components.') : invariant(false) : void 0;
|
|
47
47
|
|
|
48
48
|
var result = [];
|
|
49
49
|
|
|
50
50
|
for (var key in object) {
|
|
51
51
|
if (process.env.NODE_ENV !== 'production') {
|
|
52
52
|
if (!warnedAboutNumeric && numericPropertyRegex.test(key)) {
|
|
53
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment(...): Child objects should have ' + 'non-numeric keys so ordering is preserved.') :
|
|
53
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment(...): Child objects should have ' + 'non-numeric keys so ordering is preserved.') : void 0;
|
|
54
54
|
warnedAboutNumeric = true;
|
|
55
55
|
}
|
|
56
56
|
}
|
package/lib/ReactInjection.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
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
|
|
14
14
|
var DOMProperty = require('./DOMProperty');
|
|
15
15
|
var EventPluginHub = require('./EventPluginHub');
|
|
16
|
+
var EventPluginUtils = require('./EventPluginUtils');
|
|
16
17
|
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
|
|
17
18
|
var ReactClass = require('./ReactClass');
|
|
18
19
|
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
19
20
|
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
20
21
|
var ReactNativeComponent = require('./ReactNativeComponent');
|
|
21
22
|
var ReactPerf = require('./ReactPerf');
|
|
22
|
-
var ReactRootIndex = require('./ReactRootIndex');
|
|
23
23
|
var ReactUpdates = require('./ReactUpdates');
|
|
24
24
|
|
|
25
25
|
var ReactInjection = {
|
|
@@ -28,10 +28,10 @@ var ReactInjection = {
|
|
|
28
28
|
DOMProperty: DOMProperty.injection,
|
|
29
29
|
EmptyComponent: ReactEmptyComponent.injection,
|
|
30
30
|
EventPluginHub: EventPluginHub.injection,
|
|
31
|
+
EventPluginUtils: EventPluginUtils.injection,
|
|
31
32
|
EventEmitter: ReactBrowserEventEmitter.injection,
|
|
32
33
|
NativeComponent: ReactNativeComponent.injection,
|
|
33
34
|
Perf: ReactPerf.injection,
|
|
34
|
-
RootIndex: ReactRootIndex.injection,
|
|
35
35
|
Updates: ReactUpdates.injection
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -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
|
|
@@ -74,7 +74,7 @@ var ReactInputSelection = {
|
|
|
74
74
|
start: input.selectionStart,
|
|
75
75
|
end: input.selectionEnd
|
|
76
76
|
};
|
|
77
|
-
} else if (document.selection &&
|
|
77
|
+
} else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
|
|
78
78
|
// IE8 input.
|
|
79
79
|
var range = document.selection.createRange();
|
|
80
80
|
// There can only be one selection per document in IE, so it must
|
|
@@ -102,14 +102,14 @@ var ReactInputSelection = {
|
|
|
102
102
|
setSelection: function (input, offsets) {
|
|
103
103
|
var start = offsets.start;
|
|
104
104
|
var end = offsets.end;
|
|
105
|
-
if (
|
|
105
|
+
if (end === undefined) {
|
|
106
106
|
end = start;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
if ('selectionStart' in input) {
|
|
110
110
|
input.selectionStart = start;
|
|
111
111
|
input.selectionEnd = Math.min(end, input.value.length);
|
|
112
|
-
} else if (document.selection &&
|
|
112
|
+
} else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
|
|
113
113
|
var range = input.createTextRange();
|
|
114
114
|
range.collapse(true);
|
|
115
115
|
range.moveStart('character', start);
|
|
@@ -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,13 +7,10 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactInstanceHandles
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
15
|
-
var ReactRootIndex = require('./ReactRootIndex');
|
|
16
|
-
|
|
17
14
|
var invariant = require('fbjs/lib/invariant');
|
|
18
15
|
|
|
19
16
|
var SEPARATOR = '.';
|
|
@@ -91,8 +88,8 @@ function getParentID(id) {
|
|
|
91
88
|
* @private
|
|
92
89
|
*/
|
|
93
90
|
function getNextDescendantID(ancestorID, destinationID) {
|
|
94
|
-
!(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) :
|
|
95
|
-
!isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) :
|
|
91
|
+
!(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : void 0;
|
|
92
|
+
!isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : void 0;
|
|
96
93
|
if (ancestorID === destinationID) {
|
|
97
94
|
return ancestorID;
|
|
98
95
|
}
|
|
@@ -134,7 +131,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
134
131
|
}
|
|
135
132
|
}
|
|
136
133
|
var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
|
|
137
|
-
!isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) :
|
|
134
|
+
!isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : void 0;
|
|
138
135
|
return longestCommonID;
|
|
139
136
|
}
|
|
140
137
|
|
|
@@ -154,9 +151,9 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
154
151
|
function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
155
152
|
start = start || '';
|
|
156
153
|
stop = stop || '';
|
|
157
|
-
!(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) :
|
|
154
|
+
!(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : void 0;
|
|
158
155
|
var traverseUp = isAncestorIDOf(stop, start);
|
|
159
|
-
!(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) :
|
|
156
|
+
!(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : void 0;
|
|
160
157
|
// Traverse from `start` to `stop` one depth at a time.
|
|
161
158
|
var depth = 0;
|
|
162
159
|
var traverse = traverseUp ? getParentID : getNextDescendantID;
|
|
@@ -169,7 +166,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
|
169
166
|
// Only break //after// visiting `stop`.
|
|
170
167
|
break;
|
|
171
168
|
}
|
|
172
|
-
!(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) :
|
|
169
|
+
!(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : void 0;
|
|
173
170
|
}
|
|
174
171
|
}
|
|
175
172
|
|
|
@@ -184,10 +181,11 @@ var ReactInstanceHandles = {
|
|
|
184
181
|
|
|
185
182
|
/**
|
|
186
183
|
* Constructs a React root ID
|
|
184
|
+
* @param {number} index A unique integer
|
|
187
185
|
* @return {string} A React root ID.
|
|
188
186
|
*/
|
|
189
|
-
createReactRootID: function () {
|
|
190
|
-
return getReactRootIDString(
|
|
187
|
+
createReactRootID: function (index) {
|
|
188
|
+
return getReactRootIDString(index);
|
|
191
189
|
},
|
|
192
190
|
|
|
193
191
|
/**
|