react 15.1.0 → 15.2.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/dist/react-with-addons.js +2034 -1313
- package/dist/react-with-addons.min.js +7 -6
- package/dist/react.js +1832 -1244
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/CallbackQueue.js +3 -2
- package/lib/DOMChildrenOperations.js +9 -9
- package/lib/DOMLazyTree.js +3 -2
- package/lib/DOMProperty.js +6 -4
- package/lib/DOMPropertyOperations.js +17 -3
- package/lib/Danger.js +10 -8
- package/lib/DisabledInputUtils.js +5 -5
- package/lib/EventPluginHub.js +8 -2
- package/lib/EventPluginRegistry.js +13 -7
- package/lib/EventPluginUtils.js +3 -1
- package/lib/HTMLDOMPropertyConfig.js +1 -2
- package/lib/LinkedValueUtils.js +5 -3
- package/lib/NativeMethodsMixin.js +6 -4
- package/lib/PooledClass.js +3 -1
- package/lib/React.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +15 -8
- package/lib/ReactChildReconciler.js +15 -6
- package/lib/ReactClass.js +14 -13
- package/lib/ReactComponent.js +3 -6
- package/lib/ReactComponentEnvironment.js +3 -1
- package/lib/ReactComponentTreeDevtool.js +94 -16
- package/lib/ReactComponentTreeTestUtils.js +87 -0
- package/lib/ReactCompositeComponent.js +66 -106
- package/lib/ReactDOM.js +2 -2
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +130 -76
- package/lib/ReactDOMComponentTree.js +23 -21
- package/lib/ReactDOMDebugTool.js +7 -1
- package/lib/ReactDOMEmptyComponent.js +9 -9
- package/lib/ReactDOMFactories.js +1 -1
- package/lib/ReactDOMInput.js +52 -16
- package/lib/ReactDOMOption.js +40 -26
- package/lib/ReactDOMSelect.js +3 -3
- package/lib/ReactDOMTextComponent.js +21 -20
- package/lib/ReactDOMTextarea.js +59 -32
- package/lib/ReactDOMTreeTraversal.js +18 -16
- package/lib/ReactDOMUnknownPropertyDevtool.js +41 -15
- package/lib/ReactDebugTool.js +88 -27
- package/lib/ReactDefaultInjection.js +2 -2
- package/lib/ReactElement.js +64 -25
- package/lib/ReactElementValidator.js +26 -81
- package/lib/ReactEventListener.js +2 -2
- package/lib/ReactFragment.js +3 -1
- package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
- package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +5 -5
- package/lib/ReactInjection.js +2 -2
- package/lib/ReactInstanceHandles.js +8 -6
- package/lib/ReactMount.js +24 -16
- package/lib/ReactMultiChild.js +31 -9
- package/lib/ReactNativeAttributePayload.js +5 -2
- package/lib/ReactNativeBaseComponent.js +7 -7
- package/lib/ReactNativeBridgeEventPlugin.js +1 -1
- package/lib/ReactNativeComponentTree.js +8 -6
- package/lib/ReactNativeDOMIDOperations.js +1 -2
- package/lib/ReactNativeDefaultInjection.js +9 -7
- package/lib/ReactNativeGlobalResponderHandler.js +1 -1
- package/lib/ReactNativeMount.js +1 -1
- package/lib/ReactNativeTagHandles.js +3 -1
- package/lib/ReactNativeTextComponent.js +10 -9
- package/lib/ReactNativeTreeTraversal.js +11 -11
- package/lib/ReactNodeTypes.js +5 -3
- package/lib/ReactNoop.js +76 -0
- package/lib/ReactOwner.js +4 -2
- package/lib/ReactPerf.js +83 -7
- package/lib/ReactPropTypes.js +23 -0
- package/lib/ReactReconcileTransaction.js +1 -1
- package/lib/ReactReconciler.js +12 -7
- package/lib/ReactServerRendering.js +4 -2
- package/lib/ReactSimpleEmptyComponent.js +4 -4
- package/lib/ReactTestMount.js +126 -0
- package/lib/ReactTestReconcileTransaction.js +100 -0
- package/lib/ReactTestRenderer.js +133 -0
- package/lib/ReactTestUtils.js +17 -10
- package/lib/ReactTransitionChildMapping.js +7 -1
- package/lib/ReactTransitionGroup.js +40 -6
- package/lib/ReactUpdateQueue.js +9 -1
- package/lib/ReactUpdates.js +9 -8
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +8 -6
- package/lib/ResponderTouchHistoryStore.js +6 -4
- package/lib/SimpleEventPlugin.js +3 -1
- package/lib/SyntheticEvent.js +2 -3
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/Transaction.js +4 -2
- package/lib/accumulate.js +3 -1
- package/lib/accumulateInto.js +3 -1
- package/lib/checkReactTypeSpec.js +71 -0
- package/lib/createReactNativeComponentClass.js +2 -2
- package/lib/dangerousStyleValue.js +3 -1
- package/lib/escapeTextContentForBrowser.js +96 -12
- package/lib/findDOMNode.js +6 -4
- package/lib/findNodeHandle.js +5 -3
- package/lib/flattenChildren.js +13 -4
- package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
- package/lib/instantiateReactComponent.js +13 -12
- package/lib/onlyChild.js +3 -1
- package/lib/reactComponentExpect.js +3 -3
- package/lib/reactProdInvariant.js +38 -0
- package/lib/setInnerHTML.js +17 -1
- package/lib/setTextContent.js +8 -0
- package/lib/traverseAllChildren.js +3 -1
- package/lib/update.js +12 -11
- package/package.json +2 -2
- package/lib/MetaMatchers.js +0 -118
package/lib/findDOMNode.js
CHANGED
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
15
17
|
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
16
18
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
17
19
|
|
|
18
|
-
var
|
|
20
|
+
var getHostComponentFromComposite = require('./getHostComponentFromComposite');
|
|
19
21
|
var invariant = require('fbjs/lib/invariant');
|
|
20
22
|
var warning = require('fbjs/lib/warning');
|
|
21
23
|
|
|
@@ -44,14 +46,14 @@ function findDOMNode(componentOrElement) {
|
|
|
44
46
|
|
|
45
47
|
var inst = ReactInstanceMap.get(componentOrElement);
|
|
46
48
|
if (inst) {
|
|
47
|
-
inst =
|
|
49
|
+
inst = getHostComponentFromComposite(inst);
|
|
48
50
|
return inst ? ReactDOMComponentTree.getNodeFromInstance(inst) : null;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
if (typeof componentOrElement.render === 'function') {
|
|
52
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') :
|
|
54
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : _prodInvariant('44') : void 0;
|
|
53
55
|
} else {
|
|
54
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) :
|
|
56
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : _prodInvariant('45', Object.keys(componentOrElement)) : void 0;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
package/lib/findNodeHandle.js
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
16
|
+
|
|
15
17
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
16
18
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
17
19
|
|
|
@@ -70,7 +72,7 @@ function findNodeHandle(componentOrHandle) {
|
|
|
70
72
|
// ReactInstanceMap.get here will always succeed for mounted components
|
|
71
73
|
var internalInstance = ReactInstanceMap.get(component);
|
|
72
74
|
if (internalInstance) {
|
|
73
|
-
return internalInstance.
|
|
75
|
+
return internalInstance.getHostNode();
|
|
74
76
|
} else {
|
|
75
77
|
var rootNodeID = component._rootNodeID;
|
|
76
78
|
if (rootNodeID) {
|
|
@@ -80,8 +82,8 @@ function findNodeHandle(componentOrHandle) {
|
|
|
80
82
|
// Native
|
|
81
83
|
typeof component === 'object' && '_rootNodeID' in component ||
|
|
82
84
|
// Composite
|
|
83
|
-
component.render != null && typeof component.render === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Argument is not a component
|
|
84
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Unable to find node handle for unmounted
|
|
85
|
+
component.render != null && typeof component.render === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Argument is not a component (type: %s, keys: %s)', typeof component, Object.keys(component)) : _prodInvariant('21', typeof component, Object.keys(component)) : void 0;
|
|
86
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findNodeHandle(...): Unable to find node handle for unmounted component.') : _prodInvariant('22') : void 0;
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
}
|
package/lib/flattenChildren.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
|
|
14
15
|
var KeyEscapeUtils = require('./KeyEscapeUtils');
|
|
15
16
|
var traverseAllChildren = require('./traverseAllChildren');
|
|
16
17
|
var warning = require('fbjs/lib/warning');
|
|
@@ -19,13 +20,14 @@ var warning = require('fbjs/lib/warning');
|
|
|
19
20
|
* @param {function} traverseContext Context passed through traversal.
|
|
20
21
|
* @param {?ReactComponent} child React child component.
|
|
21
22
|
* @param {!string} name String name of key path to child.
|
|
23
|
+
* @param {number=} selfDebugID Optional debugID of the current internal instance.
|
|
22
24
|
*/
|
|
23
|
-
function flattenSingleChildIntoContext(traverseContext, child, name) {
|
|
25
|
+
function flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID) {
|
|
24
26
|
// We found a component instance.
|
|
25
27
|
var result = traverseContext;
|
|
26
28
|
var keyUnique = result[name] === undefined;
|
|
27
29
|
if (process.env.NODE_ENV !== 'production') {
|
|
28
|
-
process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used
|
|
30
|
+
process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeDevtool.getStackAddendumByID(selfDebugID)) : void 0;
|
|
29
31
|
}
|
|
30
32
|
if (keyUnique && child != null) {
|
|
31
33
|
result[name] = child;
|
|
@@ -37,12 +39,19 @@ function flattenSingleChildIntoContext(traverseContext, child, name) {
|
|
|
37
39
|
* children will not be included in the resulting object.
|
|
38
40
|
* @return {!object} flattened children keyed by name.
|
|
39
41
|
*/
|
|
40
|
-
function flattenChildren(children) {
|
|
42
|
+
function flattenChildren(children, selfDebugID) {
|
|
41
43
|
if (children == null) {
|
|
42
44
|
return children;
|
|
43
45
|
}
|
|
44
46
|
var result = {};
|
|
45
|
-
|
|
47
|
+
|
|
48
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
49
|
+
traverseAllChildren(children, function (traverseContext, child, name) {
|
|
50
|
+
return flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID);
|
|
51
|
+
}, result);
|
|
52
|
+
} else {
|
|
53
|
+
traverseAllChildren(children, flattenSingleChildIntoContext, result);
|
|
54
|
+
}
|
|
46
55
|
return result;
|
|
47
56
|
}
|
|
48
57
|
|
|
@@ -6,25 +6,25 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
|
-
* @providesModule
|
|
9
|
+
* @providesModule getHostComponentFromComposite
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactNodeTypes = require('./ReactNodeTypes');
|
|
15
15
|
|
|
16
|
-
function
|
|
16
|
+
function getHostComponentFromComposite(inst) {
|
|
17
17
|
var type;
|
|
18
18
|
|
|
19
19
|
while ((type = inst._renderedNodeType) === ReactNodeTypes.COMPOSITE) {
|
|
20
20
|
inst = inst._renderedComponent;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
if (type === ReactNodeTypes.
|
|
23
|
+
if (type === ReactNodeTypes.HOST) {
|
|
24
24
|
return inst._renderedComponent;
|
|
25
25
|
} else if (type === ReactNodeTypes.EMPTY) {
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
module.exports =
|
|
30
|
+
module.exports = getHostComponentFromComposite;
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant'),
|
|
15
|
+
_assign = require('object-assign');
|
|
15
16
|
|
|
16
17
|
var ReactCompositeComponent = require('./ReactCompositeComponent');
|
|
17
18
|
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
18
|
-
var
|
|
19
|
+
var ReactHostComponent = require('./ReactHostComponent');
|
|
19
20
|
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
20
21
|
|
|
21
22
|
var invariant = require('fbjs/lib/invariant');
|
|
@@ -82,27 +83,32 @@ function instantiateReactComponent(node) {
|
|
|
82
83
|
instance = ReactEmptyComponent.create(instantiateReactComponent);
|
|
83
84
|
} else if (typeof node === 'object') {
|
|
84
85
|
var element = node;
|
|
85
|
-
!(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components)
|
|
86
|
+
!(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : _prodInvariant('130', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : void 0;
|
|
86
87
|
|
|
87
88
|
// Special case string values
|
|
88
89
|
if (typeof element.type === 'string') {
|
|
89
|
-
instance =
|
|
90
|
+
instance = ReactHostComponent.createInternalComponent(element);
|
|
90
91
|
} else if (isInternalComponentType(element.type)) {
|
|
91
92
|
// This is temporarily available for custom components that are not string
|
|
92
93
|
// representations. I.e. ART. Once those are updated to use the string
|
|
93
94
|
// representation, we can drop this code path.
|
|
94
95
|
instance = new element.type(element);
|
|
96
|
+
|
|
97
|
+
// We renamed this. Allow the old name for compat. :(
|
|
98
|
+
if (!instance.getHostNode) {
|
|
99
|
+
instance.getHostNode = instance.getNativeNode;
|
|
100
|
+
}
|
|
95
101
|
} else {
|
|
96
102
|
instance = new ReactCompositeComponentWrapper(element);
|
|
97
103
|
}
|
|
98
104
|
} else if (typeof node === 'string' || typeof node === 'number') {
|
|
99
|
-
instance =
|
|
105
|
+
instance = ReactHostComponent.createInstanceForText(node);
|
|
100
106
|
} else {
|
|
101
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) :
|
|
107
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : _prodInvariant('131', typeof node) : void 0;
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
if (process.env.NODE_ENV !== 'production') {
|
|
105
|
-
process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.
|
|
111
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getHostNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : void 0;
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
// These two fields are used by the DOM and ART diffing algorithms
|
|
@@ -111,11 +117,6 @@ function instantiateReactComponent(node) {
|
|
|
111
117
|
instance._mountIndex = 0;
|
|
112
118
|
instance._mountImage = null;
|
|
113
119
|
|
|
114
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
115
|
-
instance._isOwnerNecessary = false;
|
|
116
|
-
instance._warnedAboutRefsInRender = false;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
120
|
if (process.env.NODE_ENV !== 'production') {
|
|
120
121
|
var debugID = isEmpty ? 0 : nextDebugID++;
|
|
121
122
|
instance._debugID = debugID;
|
package/lib/onlyChild.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
14
|
+
|
|
13
15
|
var ReactElement = require('./ReactElement');
|
|
14
16
|
|
|
15
17
|
var invariant = require('fbjs/lib/invariant');
|
|
@@ -29,7 +31,7 @@ var invariant = require('fbjs/lib/invariant');
|
|
|
29
31
|
* structure.
|
|
30
32
|
*/
|
|
31
33
|
function onlyChild(children) {
|
|
32
|
-
!ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') :
|
|
34
|
+
!ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : _prodInvariant('23') : void 0;
|
|
33
35
|
return children;
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule reactComponentExpect
|
|
10
|
-
* @nolint
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
15
|
-
var
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant'),
|
|
15
|
+
_assign = require('object-assign');
|
|
16
16
|
|
|
17
17
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
18
18
|
var ReactTestUtils = require('./ReactTestUtils');
|
|
@@ -31,7 +31,7 @@ function reactComponentExpect(instance) {
|
|
|
31
31
|
expect(instance).not.toBeNull();
|
|
32
32
|
expect(instance).not.toBeUndefined();
|
|
33
33
|
|
|
34
|
-
!ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') :
|
|
34
|
+
!ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : _prodInvariant('15') : void 0;
|
|
35
35
|
var internalInstance = ReactInstanceMap.get(instance);
|
|
36
36
|
|
|
37
37
|
expect(typeof internalInstance).toBe('object');
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 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 reactProdInvariant
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* WARNING: DO NOT manually require this module.
|
|
15
|
+
* This is a replacement for `invariant(...)` used by the error code system
|
|
16
|
+
* and will _only_ be required by the corresponding babel pass.
|
|
17
|
+
* It always throws.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function reactProdInvariant(code) {
|
|
21
|
+
var argCount = arguments.length - 1;
|
|
22
|
+
|
|
23
|
+
var message = 'Minified React error #' + code + '; visit ' + 'http://facebook.github.io/react/docs/error-decoder.html?invariant=' + code;
|
|
24
|
+
|
|
25
|
+
for (var argIdx = 0; argIdx < argCount; argIdx++) {
|
|
26
|
+
message += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
message += ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.';
|
|
30
|
+
|
|
31
|
+
var error = new Error(message);
|
|
32
|
+
error.name = 'Invariant Violation';
|
|
33
|
+
error.framesToPop = 1; // we don't care about reactProdInvariant's own frame
|
|
34
|
+
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = reactProdInvariant;
|
package/lib/setInnerHTML.js
CHANGED
|
@@ -12,12 +12,16 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
15
|
+
var DOMNamespaces = require('./DOMNamespaces');
|
|
15
16
|
|
|
16
17
|
var WHITESPACE_TEST = /^[ \r\n\t\f]/;
|
|
17
18
|
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
|
|
18
19
|
|
|
19
20
|
var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction');
|
|
20
21
|
|
|
22
|
+
// SVG temp container for IE lacking innerHTML
|
|
23
|
+
var reusableSVGContainer;
|
|
24
|
+
|
|
21
25
|
/**
|
|
22
26
|
* Set the innerHTML property of a node, ensuring that whitespace is preserved
|
|
23
27
|
* even in IE8.
|
|
@@ -27,7 +31,19 @@ var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFu
|
|
|
27
31
|
* @internal
|
|
28
32
|
*/
|
|
29
33
|
var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
|
|
30
|
-
|
|
34
|
+
// IE does not have innerHTML for SVG nodes, so instead we inject the
|
|
35
|
+
// new markup in a temp node and then move the child nodes across into
|
|
36
|
+
// the target node
|
|
37
|
+
if (node.namespaceURI === DOMNamespaces.svg && !('innerHTML' in node)) {
|
|
38
|
+
reusableSVGContainer = reusableSVGContainer || document.createElement('div');
|
|
39
|
+
reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>';
|
|
40
|
+
var newNodes = reusableSVGContainer.firstChild.childNodes;
|
|
41
|
+
for (var i = 0; i < newNodes.length; i++) {
|
|
42
|
+
node.appendChild(newNodes[i]);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
node.innerHTML = html;
|
|
46
|
+
}
|
|
31
47
|
});
|
|
32
48
|
|
|
33
49
|
if (ExecutionEnvironment.canUseDOM) {
|
package/lib/setTextContent.js
CHANGED
|
@@ -26,6 +26,14 @@ var setInnerHTML = require('./setInnerHTML');
|
|
|
26
26
|
* @internal
|
|
27
27
|
*/
|
|
28
28
|
var setTextContent = function (node, text) {
|
|
29
|
+
if (text) {
|
|
30
|
+
var firstChild = node.firstChild;
|
|
31
|
+
|
|
32
|
+
if (firstChild && firstChild === node.lastChild && firstChild.nodeType === 3) {
|
|
33
|
+
firstChild.nodeValue = text;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
29
37
|
node.textContent = text;
|
|
30
38
|
};
|
|
31
39
|
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
15
17
|
var ReactElement = require('./ReactElement');
|
|
16
18
|
|
|
@@ -124,7 +126,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
var childrenString = String(children);
|
|
127
|
-
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) :
|
|
129
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : _prodInvariant('31', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : void 0;
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
|
package/lib/update.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _prodInvariant = require('./reactProdInvariant'),
|
|
17
|
+
_assign = require('object-assign');
|
|
17
18
|
|
|
18
19
|
var keyOf = require('fbjs/lib/keyOf');
|
|
19
20
|
var invariant = require('fbjs/lib/invariant');
|
|
@@ -45,9 +46,9 @@ ALL_COMMANDS_LIST.forEach(function (command) {
|
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
function invariantArrayCase(value, spec, command) {
|
|
48
|
-
!Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected target of %s to be an array; got %s.', command, value) :
|
|
49
|
+
!Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected target of %s to be an array; got %s.', command, value) : _prodInvariant('1', command, value) : void 0;
|
|
49
50
|
var specValue = spec[command];
|
|
50
|
-
!Array.isArray(specValue) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array; got %s.
|
|
51
|
+
!Array.isArray(specValue) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array; got %s. Did you forget to wrap your parameter in an array?', command, specValue) : _prodInvariant('2', command, specValue) : void 0;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
/**
|
|
@@ -55,10 +56,10 @@ function invariantArrayCase(value, spec, command) {
|
|
|
55
56
|
* See https://facebook.github.io/react/docs/update.html for details.
|
|
56
57
|
*/
|
|
57
58
|
function update(value, spec) {
|
|
58
|
-
!(typeof spec === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): You provided a key path to update() that did not contain one
|
|
59
|
+
!(typeof spec === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): You provided a key path to update() that did not contain one of %s. Did you forget to include {%s: ...}?', ALL_COMMANDS_LIST.join(', '), COMMAND_SET) : _prodInvariant('3', ALL_COMMANDS_LIST.join(', '), COMMAND_SET) : void 0;
|
|
59
60
|
|
|
60
61
|
if (hasOwnProperty.call(spec, COMMAND_SET)) {
|
|
61
|
-
!(Object.keys(spec).length === 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot have more than one key in an object with %s', COMMAND_SET) :
|
|
62
|
+
!(Object.keys(spec).length === 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot have more than one key in an object with %s', COMMAND_SET) : _prodInvariant('4', COMMAND_SET) : void 0;
|
|
62
63
|
|
|
63
64
|
return spec[COMMAND_SET];
|
|
64
65
|
}
|
|
@@ -67,8 +68,8 @@ function update(value, spec) {
|
|
|
67
68
|
|
|
68
69
|
if (hasOwnProperty.call(spec, COMMAND_MERGE)) {
|
|
69
70
|
var mergeObj = spec[COMMAND_MERGE];
|
|
70
|
-
!(mergeObj && typeof mergeObj === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a spec of type \'object\'; got %s', COMMAND_MERGE, mergeObj) :
|
|
71
|
-
!(nextValue && typeof nextValue === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a target of type \'object\'; got %s', COMMAND_MERGE, nextValue) :
|
|
71
|
+
!(mergeObj && typeof mergeObj === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a spec of type \'object\'; got %s', COMMAND_MERGE, mergeObj) : _prodInvariant('5', COMMAND_MERGE, mergeObj) : void 0;
|
|
72
|
+
!(nextValue && typeof nextValue === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): %s expects a target of type \'object\'; got %s', COMMAND_MERGE, nextValue) : _prodInvariant('6', COMMAND_MERGE, nextValue) : void 0;
|
|
72
73
|
_assign(nextValue, spec[COMMAND_MERGE]);
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -87,16 +88,16 @@ function update(value, spec) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
if (hasOwnProperty.call(spec, COMMAND_SPLICE)) {
|
|
90
|
-
!Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s target to be an array; got %s', COMMAND_SPLICE, value) :
|
|
91
|
-
!Array.isArray(spec[COMMAND_SPLICE]) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s.
|
|
91
|
+
!Array.isArray(value) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s target to be an array; got %s', COMMAND_SPLICE, value) : _prodInvariant('7', COMMAND_SPLICE, value) : void 0;
|
|
92
|
+
!Array.isArray(spec[COMMAND_SPLICE]) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : _prodInvariant('8', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : void 0;
|
|
92
93
|
spec[COMMAND_SPLICE].forEach(function (args) {
|
|
93
|
-
!Array.isArray(args) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s.
|
|
94
|
+
!Array.isArray(args) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array of arrays; got %s. Did you forget to wrap your parameters in an array?', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : _prodInvariant('8', COMMAND_SPLICE, spec[COMMAND_SPLICE]) : void 0;
|
|
94
95
|
nextValue.splice.apply(nextValue, args);
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
if (hasOwnProperty.call(spec, COMMAND_APPLY)) {
|
|
99
|
-
!(typeof spec[COMMAND_APPLY] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be a function; got %s.', COMMAND_APPLY, spec[COMMAND_APPLY]) :
|
|
100
|
+
!(typeof spec[COMMAND_APPLY] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'update(): expected spec of %s to be a function; got %s.', COMMAND_APPLY, spec[COMMAND_APPLY]) : _prodInvariant('9', COMMAND_APPLY, spec[COMMAND_APPLY]) : void 0;
|
|
100
101
|
nextValue = spec[COMMAND_APPLY](nextValue);
|
|
101
102
|
}
|
|
102
103
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react",
|
|
3
3
|
"description": "React is a JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.2.0-rc.1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react"
|
|
7
7
|
],
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"node": ">=0.10.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"fbjs": "^0.8.
|
|
26
|
+
"fbjs": "^0.8.1",
|
|
27
27
|
"loose-envify": "^1.1.0",
|
|
28
28
|
"object-assign": "^4.1.0"
|
|
29
29
|
},
|
package/lib/MetaMatchers.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
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 MetaMatchers
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* This modules adds a jasmine matcher toEqualSpecsIn that can be used to
|
|
16
|
-
* compare the specs in two different "describe" functions and their result.
|
|
17
|
-
* It can be used to test a test.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
function getRunnerWithResults(describeFunction) {
|
|
21
|
-
if (describeFunction._cachedRunner) {
|
|
22
|
-
// Cached result of execution. This is a convenience way to test against
|
|
23
|
-
// the same authoritative function multiple times.
|
|
24
|
-
return describeFunction._cachedRunner;
|
|
25
|
-
}
|
|
26
|
-
// Patch the current global environment.
|
|
27
|
-
var env = new jasmine.Env();
|
|
28
|
-
// Execute the tests synchronously.
|
|
29
|
-
env.updateInterval = 0;
|
|
30
|
-
var outerGetEnv = jasmine.getEnv;
|
|
31
|
-
jasmine.getEnv = function () {
|
|
32
|
-
return env;
|
|
33
|
-
};
|
|
34
|
-
// TODO: Bring over matchers from the existing environment.
|
|
35
|
-
var runner = env.currentRunner();
|
|
36
|
-
try {
|
|
37
|
-
env.describe('', describeFunction);
|
|
38
|
-
env.execute();
|
|
39
|
-
} finally {
|
|
40
|
-
// Restore the environment.
|
|
41
|
-
jasmine.getEnv = outerGetEnv;
|
|
42
|
-
}
|
|
43
|
-
describeFunction._cachedRunner = runner;
|
|
44
|
-
return runner;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function compareSpec(actual, expected) {
|
|
48
|
-
if (actual.results().totalCount !== expected.results().totalCount) {
|
|
49
|
-
return 'Expected ' + expected.results().totalCount + ' expects, ' + 'but got ' + actual.results().totalCount + ':' + actual.getFullName();
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function includesDescription(specs, description, startIndex) {
|
|
55
|
-
for (var i = startIndex; i < specs.length; i++) {
|
|
56
|
-
if (specs[i].description === description) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function compareSpecs(actualSpecs, expectedSpecs) {
|
|
64
|
-
for (var i = 0; i < actualSpecs.length && i < expectedSpecs.length; i++) {
|
|
65
|
-
var actual = actualSpecs[i];
|
|
66
|
-
var expected = expectedSpecs[i];
|
|
67
|
-
if (actual.description === expected.description) {
|
|
68
|
-
var errorMessage = compareSpec(actual, expected);
|
|
69
|
-
if (errorMessage) {
|
|
70
|
-
return errorMessage;
|
|
71
|
-
}
|
|
72
|
-
continue;
|
|
73
|
-
} else if (includesDescription(actualSpecs, expected.description, i)) {
|
|
74
|
-
return 'Did not expect the spec:' + actualSpecs[i].getFullName();
|
|
75
|
-
} else {
|
|
76
|
-
return 'Expected an equivalent to:' + expectedSpecs[i].getFullName();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (i < actualSpecs.length) {
|
|
80
|
-
return 'Did not expect the spec:' + actualSpecs[i].getFullName();
|
|
81
|
-
}
|
|
82
|
-
if (i < expectedSpecs.length) {
|
|
83
|
-
return 'Expected an equivalent to:' + expectedSpecs[i].getFullName();
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function compareDescription(a, b) {
|
|
89
|
-
if (a.description === b.description) {
|
|
90
|
-
return 0;
|
|
91
|
-
}
|
|
92
|
-
return a.description < b.description ? -1 : 1;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function compareRunners(actual, expected) {
|
|
96
|
-
return compareSpecs(actual.specs().sort(compareDescription), expected.specs().sort(compareDescription));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var MetaMatchers = {
|
|
100
|
-
toEqualSpecsIn: function (expectedDescribeFunction) {
|
|
101
|
-
var actualDescribeFunction = this.actual;
|
|
102
|
-
if (typeof actualDescribeFunction !== 'function') {
|
|
103
|
-
throw Error('toEqualSpecsIn() should be used on a describe function');
|
|
104
|
-
}
|
|
105
|
-
if (typeof expectedDescribeFunction !== 'function') {
|
|
106
|
-
throw Error('toEqualSpecsIn() should be passed a describe function');
|
|
107
|
-
}
|
|
108
|
-
var actual = getRunnerWithResults(actualDescribeFunction);
|
|
109
|
-
var expected = getRunnerWithResults(expectedDescribeFunction);
|
|
110
|
-
var errorMessage = compareRunners(actual, expected);
|
|
111
|
-
this.message = function () {
|
|
112
|
-
return [errorMessage, 'The specs are equal. Expected them to be different.'];
|
|
113
|
-
};
|
|
114
|
-
return !errorMessage;
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
module.exports = MetaMatchers;
|