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/ReactDOMTextarea.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,14 +11,20 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
16
|
+
var DOMPropertyOperations = require('./DOMPropertyOperations');
|
|
14
17
|
var LinkedValueUtils = require('./LinkedValueUtils');
|
|
15
|
-
var
|
|
18
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
16
19
|
var ReactUpdates = require('./ReactUpdates');
|
|
17
20
|
|
|
18
|
-
var assign = require('./Object.assign');
|
|
19
21
|
var invariant = require('fbjs/lib/invariant');
|
|
20
22
|
var warning = require('fbjs/lib/warning');
|
|
21
23
|
|
|
24
|
+
var didWarnValueLink = false;
|
|
25
|
+
var didWarnValueNull = false;
|
|
26
|
+
var didWarnValDefaultVal = false;
|
|
27
|
+
|
|
22
28
|
function forceUpdateIfMounted() {
|
|
23
29
|
if (this._rootNodeID) {
|
|
24
30
|
// DOM component is still mounted; update
|
|
@@ -26,6 +32,14 @@ function forceUpdateIfMounted() {
|
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
function warnIfValueIsNull(props) {
|
|
36
|
+
if (props != null && props.value === null && !didWarnValueNull) {
|
|
37
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '`value` prop on `textarea` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.') : void 0;
|
|
38
|
+
|
|
39
|
+
didWarnValueNull = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
/**
|
|
30
44
|
* Implements a <textarea> native component that allows setting `value`, and
|
|
31
45
|
* `defaultValue`. This differs from the traditional DOM API because value is
|
|
@@ -42,12 +56,12 @@ function forceUpdateIfMounted() {
|
|
|
42
56
|
* `defaultValue` if specified, or the children content (deprecated).
|
|
43
57
|
*/
|
|
44
58
|
var ReactDOMTextarea = {
|
|
45
|
-
getNativeProps: function (inst, props
|
|
46
|
-
!(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) :
|
|
59
|
+
getNativeProps: function (inst, props) {
|
|
60
|
+
!(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : void 0;
|
|
47
61
|
|
|
48
62
|
// Always set children to the same thing. In IE9, the selection range will
|
|
49
63
|
// get reset if `textContent` is mutated.
|
|
50
|
-
var nativeProps =
|
|
64
|
+
var nativeProps = _assign({}, props, {
|
|
51
65
|
defaultValue: undefined,
|
|
52
66
|
value: undefined,
|
|
53
67
|
children: inst._wrapperState.initialValue,
|
|
@@ -60,6 +74,15 @@ var ReactDOMTextarea = {
|
|
|
60
74
|
mountWrapper: function (inst, props) {
|
|
61
75
|
if (process.env.NODE_ENV !== 'production') {
|
|
62
76
|
LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
|
|
77
|
+
if (props.valueLink !== undefined && !didWarnValueLink) {
|
|
78
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `textarea` is deprecated; set `value` and `onChange` instead.') : void 0;
|
|
79
|
+
didWarnValueLink = true;
|
|
80
|
+
}
|
|
81
|
+
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
|
|
82
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components') : void 0;
|
|
83
|
+
didWarnValDefaultVal = true;
|
|
84
|
+
}
|
|
85
|
+
warnIfValueIsNull(props);
|
|
63
86
|
}
|
|
64
87
|
|
|
65
88
|
var defaultValue = props.defaultValue;
|
|
@@ -67,11 +90,11 @@ var ReactDOMTextarea = {
|
|
|
67
90
|
var children = props.children;
|
|
68
91
|
if (children != null) {
|
|
69
92
|
if (process.env.NODE_ENV !== 'production') {
|
|
70
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') :
|
|
93
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : void 0;
|
|
71
94
|
}
|
|
72
|
-
!(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) :
|
|
95
|
+
!(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : void 0;
|
|
73
96
|
if (Array.isArray(children)) {
|
|
74
|
-
!(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) :
|
|
97
|
+
!(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : void 0;
|
|
75
98
|
children = children[0];
|
|
76
99
|
}
|
|
77
100
|
|
|
@@ -81,24 +104,29 @@ var ReactDOMTextarea = {
|
|
|
81
104
|
defaultValue = '';
|
|
82
105
|
}
|
|
83
106
|
var value = LinkedValueUtils.getValue(props);
|
|
84
|
-
|
|
85
107
|
inst._wrapperState = {
|
|
86
108
|
// We save the initial value so that `ReactDOMComponent` doesn't update
|
|
87
109
|
// `textContent` (unnecessary since we update value).
|
|
88
110
|
// The initial value can be a boolean or object so that's why it's
|
|
89
111
|
// forced to be a string.
|
|
90
112
|
initialValue: '' + (value != null ? value : defaultValue),
|
|
113
|
+
listeners: null,
|
|
91
114
|
onChange: _handleChange.bind(inst)
|
|
92
115
|
};
|
|
93
116
|
},
|
|
94
117
|
|
|
95
118
|
updateWrapper: function (inst) {
|
|
96
119
|
var props = inst._currentElement.props;
|
|
120
|
+
|
|
121
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
122
|
+
warnIfValueIsNull(props);
|
|
123
|
+
}
|
|
124
|
+
|
|
97
125
|
var value = LinkedValueUtils.getValue(props);
|
|
98
126
|
if (value != null) {
|
|
99
127
|
// Cast `value` to a string to ensure the value is set correctly. While
|
|
100
128
|
// browsers typically do this as necessary, jsdom doesn't.
|
|
101
|
-
|
|
129
|
+
DOMPropertyOperations.setValueForProperty(ReactDOMComponentTree.getNodeFromInstance(inst), 'value', '' + value);
|
|
102
130
|
}
|
|
103
131
|
}
|
|
104
132
|
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactDOMTreeTraversal
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var invariant = require('fbjs/lib/invariant');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Return the lowest common ancestor of A and B, or null if they are in
|
|
18
|
+
* different trees.
|
|
19
|
+
*/
|
|
20
|
+
function getLowestCommonAncestor(instA, instB) {
|
|
21
|
+
!('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : void 0;
|
|
22
|
+
!('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : void 0;
|
|
23
|
+
|
|
24
|
+
var depthA = 0;
|
|
25
|
+
for (var tempA = instA; tempA; tempA = tempA._nativeParent) {
|
|
26
|
+
depthA++;
|
|
27
|
+
}
|
|
28
|
+
var depthB = 0;
|
|
29
|
+
for (var tempB = instB; tempB; tempB = tempB._nativeParent) {
|
|
30
|
+
depthB++;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// If A is deeper, crawl up.
|
|
34
|
+
while (depthA - depthB > 0) {
|
|
35
|
+
instA = instA._nativeParent;
|
|
36
|
+
depthA--;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// If B is deeper, crawl up.
|
|
40
|
+
while (depthB - depthA > 0) {
|
|
41
|
+
instB = instB._nativeParent;
|
|
42
|
+
depthB--;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Walk in lockstep until we find a match.
|
|
46
|
+
var depth = depthA;
|
|
47
|
+
while (depth--) {
|
|
48
|
+
if (instA === instB) {
|
|
49
|
+
return instA;
|
|
50
|
+
}
|
|
51
|
+
instA = instA._nativeParent;
|
|
52
|
+
instB = instB._nativeParent;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Return if A is an ancestor of B.
|
|
59
|
+
*/
|
|
60
|
+
function isAncestor(instA, instB) {
|
|
61
|
+
!('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) : void 0;
|
|
62
|
+
!('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) : void 0;
|
|
63
|
+
|
|
64
|
+
while (instB) {
|
|
65
|
+
if (instB === instA) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
instB = instB._nativeParent;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Return the parent instance of the passed-in instance.
|
|
75
|
+
*/
|
|
76
|
+
function getParentInstance(inst) {
|
|
77
|
+
!('_nativeNode' in inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getParentInstance: Invalid argument.') : invariant(false) : void 0;
|
|
78
|
+
|
|
79
|
+
return inst._nativeParent;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Simulates the traversal of a two-phase, capture/bubble event dispatch.
|
|
84
|
+
*/
|
|
85
|
+
function traverseTwoPhase(inst, fn, arg) {
|
|
86
|
+
var path = [];
|
|
87
|
+
while (inst) {
|
|
88
|
+
path.push(inst);
|
|
89
|
+
inst = inst._nativeParent;
|
|
90
|
+
}
|
|
91
|
+
var i;
|
|
92
|
+
for (i = path.length; i-- > 0;) {
|
|
93
|
+
fn(path[i], false, arg);
|
|
94
|
+
}
|
|
95
|
+
for (i = 0; i < path.length; i++) {
|
|
96
|
+
fn(path[i], true, arg);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
|
|
102
|
+
* should would receive a `mouseEnter` or `mouseLeave` event.
|
|
103
|
+
*
|
|
104
|
+
* Does not invoke the callback on the nearest common ancestor because nothing
|
|
105
|
+
* "entered" or "left" that element.
|
|
106
|
+
*/
|
|
107
|
+
function traverseEnterLeave(from, to, fn, argFrom, argTo) {
|
|
108
|
+
var common = from && to ? getLowestCommonAncestor(from, to) : null;
|
|
109
|
+
var pathFrom = [];
|
|
110
|
+
while (from && from !== common) {
|
|
111
|
+
pathFrom.push(from);
|
|
112
|
+
from = from._nativeParent;
|
|
113
|
+
}
|
|
114
|
+
var pathTo = [];
|
|
115
|
+
while (to && to !== common) {
|
|
116
|
+
pathTo.push(to);
|
|
117
|
+
to = to._nativeParent;
|
|
118
|
+
}
|
|
119
|
+
var i;
|
|
120
|
+
for (i = 0; i < pathFrom.length; i++) {
|
|
121
|
+
fn(pathFrom[i], true, argFrom);
|
|
122
|
+
}
|
|
123
|
+
for (i = pathTo.length; i-- > 0;) {
|
|
124
|
+
fn(pathTo[i], false, argTo);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = {
|
|
129
|
+
isAncestor: isAncestor,
|
|
130
|
+
getLowestCommonAncestor: getLowestCommonAncestor,
|
|
131
|
+
getParentInstance: getParentInstance,
|
|
132
|
+
traverseTwoPhase: traverseTwoPhase,
|
|
133
|
+
traverseEnterLeave: traverseEnterLeave
|
|
134
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
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 ReactDOMUnknownPropertyDevtool
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var DOMProperty = require('./DOMProperty');
|
|
15
|
+
var EventPluginRegistry = require('./EventPluginRegistry');
|
|
16
|
+
|
|
17
|
+
var warning = require('fbjs/lib/warning');
|
|
18
|
+
|
|
19
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
+
var reactProps = {
|
|
21
|
+
children: true,
|
|
22
|
+
dangerouslySetInnerHTML: true,
|
|
23
|
+
key: true,
|
|
24
|
+
ref: true
|
|
25
|
+
};
|
|
26
|
+
var warnedProperties = {};
|
|
27
|
+
|
|
28
|
+
var warnUnknownProperty = function (name) {
|
|
29
|
+
if (DOMProperty.properties.hasOwnProperty(name) || DOMProperty.isCustomAttribute(name)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
warnedProperties[name] = true;
|
|
37
|
+
var lowerCasedName = name.toLowerCase();
|
|
38
|
+
|
|
39
|
+
// data-* attributes should be lowercase; suggest the lowercase version
|
|
40
|
+
var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
|
|
41
|
+
|
|
42
|
+
// For now, only warn when we have a suggested correction. This prevents
|
|
43
|
+
// logging too much when using transferPropsTo.
|
|
44
|
+
process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : void 0;
|
|
45
|
+
|
|
46
|
+
var registrationName = EventPluginRegistry.possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? EventPluginRegistry.possibleRegistrationNames[lowerCasedName] : null;
|
|
47
|
+
|
|
48
|
+
process.env.NODE_ENV !== 'production' ? warning(registrationName == null, 'Unknown event handler property %s. Did you mean `%s`?', name, registrationName) : void 0;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var ReactDOMUnknownPropertyDevtool = {
|
|
53
|
+
onCreateMarkupForProperty: function (name, value) {
|
|
54
|
+
warnUnknownProperty(name);
|
|
55
|
+
},
|
|
56
|
+
onSetValueForProperty: function (node, name, value) {
|
|
57
|
+
warnUnknownProperty(name);
|
|
58
|
+
},
|
|
59
|
+
onDeleteValueForProperty: function (node, name) {
|
|
60
|
+
warnUnknownProperty(name);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = ReactDOMUnknownPropertyDevtool;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016-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 ReactDebugInstanceMap
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var warning = require('fbjs/lib/warning');
|
|
15
|
+
|
|
16
|
+
function checkValidInstance(internalInstance) {
|
|
17
|
+
if (!internalInstance) {
|
|
18
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'There is an internal error in the React developer tools integration. ' + 'Instead of an internal instance, received %s. ' + 'Please report this as a bug in React.', internalInstance) : void 0;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var isValid = typeof internalInstance.mountComponent === 'function';
|
|
22
|
+
process.env.NODE_ENV !== 'production' ? warning(isValid, 'There is an internal error in the React developer tools integration. ' + 'Instead of an internal instance, received an object with the following ' + 'keys: %s. Please report this as a bug in React.', Object.keys(internalInstance).join(', ')) : void 0;
|
|
23
|
+
return isValid;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var idCounter = 1;
|
|
27
|
+
var instancesByIDs = {};
|
|
28
|
+
var instancesToIDs;
|
|
29
|
+
|
|
30
|
+
function getIDForInstance(internalInstance) {
|
|
31
|
+
if (!instancesToIDs) {
|
|
32
|
+
instancesToIDs = new WeakMap();
|
|
33
|
+
}
|
|
34
|
+
if (instancesToIDs.has(internalInstance)) {
|
|
35
|
+
return instancesToIDs.get(internalInstance);
|
|
36
|
+
} else {
|
|
37
|
+
var instanceID = (idCounter++).toString();
|
|
38
|
+
instancesToIDs.set(internalInstance, instanceID);
|
|
39
|
+
return instanceID;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getInstanceByID(instanceID) {
|
|
44
|
+
return instancesByIDs[instanceID] || null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function isRegisteredInstance(internalInstance) {
|
|
48
|
+
var instanceID = getIDForInstance(internalInstance);
|
|
49
|
+
if (instanceID) {
|
|
50
|
+
return instancesByIDs.hasOwnProperty(instanceID);
|
|
51
|
+
} else {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function registerInstance(internalInstance) {
|
|
57
|
+
var instanceID = getIDForInstance(internalInstance);
|
|
58
|
+
if (instanceID) {
|
|
59
|
+
instancesByIDs[instanceID] = internalInstance;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function unregisterInstance(internalInstance) {
|
|
64
|
+
var instanceID = getIDForInstance(internalInstance);
|
|
65
|
+
if (instanceID) {
|
|
66
|
+
delete instancesByIDs[instanceID];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var ReactDebugInstanceMap = {
|
|
71
|
+
getIDForInstance: function (internalInstance) {
|
|
72
|
+
if (!checkValidInstance(internalInstance)) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return getIDForInstance(internalInstance);
|
|
76
|
+
},
|
|
77
|
+
getInstanceByID: function (instanceID) {
|
|
78
|
+
return getInstanceByID(instanceID);
|
|
79
|
+
},
|
|
80
|
+
isRegisteredInstance: function (internalInstance) {
|
|
81
|
+
if (!checkValidInstance(internalInstance)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return isRegisteredInstance(internalInstance);
|
|
85
|
+
},
|
|
86
|
+
registerInstance: function (internalInstance) {
|
|
87
|
+
if (!checkValidInstance(internalInstance)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
process.env.NODE_ENV !== 'production' ? warning(!isRegisteredInstance(internalInstance), 'There is an internal error in the React developer tools integration. ' + 'A registered instance should not be registered again. ' + 'Please report this as a bug in React.') : void 0;
|
|
91
|
+
registerInstance(internalInstance);
|
|
92
|
+
},
|
|
93
|
+
unregisterInstance: function (internalInstance) {
|
|
94
|
+
if (!checkValidInstance(internalInstance)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
process.env.NODE_ENV !== 'production' ? warning(isRegisteredInstance(internalInstance), 'There is an internal error in the React developer tools integration. ' + 'An unregistered instance should not be unregistered again. ' + 'Please report this as a bug in React.') : void 0;
|
|
98
|
+
unregisterInstance(internalInstance);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
module.exports = ReactDebugInstanceMap;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016-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 ReactDebugTool
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactInvalidSetStateWarningDevTool = require('./ReactInvalidSetStateWarningDevTool');
|
|
15
|
+
var warning = require('fbjs/lib/warning');
|
|
16
|
+
|
|
17
|
+
var eventHandlers = [];
|
|
18
|
+
var handlerDoesThrowForEvent = {};
|
|
19
|
+
|
|
20
|
+
function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
|
|
21
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
22
|
+
eventHandlers.forEach(function (handler) {
|
|
23
|
+
try {
|
|
24
|
+
if (handler[handlerFunctionName]) {
|
|
25
|
+
handler[handlerFunctionName](arg1, arg2, arg3, arg4, arg5);
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
process.env.NODE_ENV !== 'production' ? warning(!handlerDoesThrowForEvent[handlerFunctionName], 'exception thrown by devtool while handling %s: %s', handlerFunctionName, e.message) : void 0;
|
|
29
|
+
handlerDoesThrowForEvent[handlerFunctionName] = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var ReactDebugTool = {
|
|
36
|
+
addDevtool: function (devtool) {
|
|
37
|
+
eventHandlers.push(devtool);
|
|
38
|
+
},
|
|
39
|
+
removeDevtool: function (devtool) {
|
|
40
|
+
for (var i = 0; i < eventHandlers.length; i++) {
|
|
41
|
+
if (eventHandlers[i] === devtool) {
|
|
42
|
+
eventHandlers.splice(i, 1);
|
|
43
|
+
i--;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
onBeginProcessingChildContext: function () {
|
|
48
|
+
emitEvent('onBeginProcessingChildContext');
|
|
49
|
+
},
|
|
50
|
+
onEndProcessingChildContext: function () {
|
|
51
|
+
emitEvent('onEndProcessingChildContext');
|
|
52
|
+
},
|
|
53
|
+
onSetState: function () {
|
|
54
|
+
emitEvent('onSetState');
|
|
55
|
+
},
|
|
56
|
+
onMountRootComponent: function (internalInstance) {
|
|
57
|
+
emitEvent('onMountRootComponent', internalInstance);
|
|
58
|
+
},
|
|
59
|
+
onMountComponent: function (internalInstance) {
|
|
60
|
+
emitEvent('onMountComponent', internalInstance);
|
|
61
|
+
},
|
|
62
|
+
onUpdateComponent: function (internalInstance) {
|
|
63
|
+
emitEvent('onUpdateComponent', internalInstance);
|
|
64
|
+
},
|
|
65
|
+
onUnmountComponent: function (internalInstance) {
|
|
66
|
+
emitEvent('onUnmountComponent', internalInstance);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
ReactDebugTool.addDevtool(ReactInvalidSetStateWarningDevTool);
|
|
71
|
+
|
|
72
|
+
module.exports = ReactDebugTool;
|