react 0.13.3 → 0.14.0-beta1
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/README.md +5 -2
- package/addons.js +7 -0
- package/dist/JSXTransformer.js +4101 -2432
- package/dist/react-with-addons.js +4389 -6277
- package/dist/react-with-addons.min.js +6 -8
- package/dist/react.js +4028 -5697
- package/dist/react.min.js +5 -6
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
- package/lib/BeforeInputEventPlugin.js +30 -118
- package/lib/CSSCore.js +12 -23
- package/lib/CSSProperty.js +4 -3
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +26 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +86 -147
- package/lib/DOMPropertyOperations.js +91 -67
- package/lib/Danger.js +19 -62
- package/lib/DefaultEventPluginOrder.js +2 -12
- package/lib/EnterLeaveEventPlugin.js +11 -33
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +11 -13
- package/lib/EventPluginHub.js +44 -47
- package/lib/EventPluginRegistry.js +18 -74
- package/lib/EventPluginUtils.js +33 -44
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +15 -20
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +71 -89
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +20 -11
- package/lib/React.js +9 -129
- package/lib/ReactBrowserComponentMixin.js +9 -2
- package/lib/ReactBrowserEventEmitter.js +26 -82
- package/lib/ReactCSSTransitionGroup.js +13 -24
- package/lib/ReactCSSTransitionGroupChild.js +26 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +24 -31
- package/lib/ReactClass.js +96 -267
- package/lib/ReactComponent.js +28 -57
- package/lib/ReactComponentBrowserEnvironment.js +4 -8
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +6 -7
- package/lib/ReactCompositeComponent.js +115 -381
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +4 -2
- package/lib/ReactDOMButton.js +16 -28
- package/lib/ReactDOMClient.js +90 -0
- package/lib/ReactDOMComponent.js +468 -156
- package/lib/ReactDOMIDOperations.js +25 -22
- package/lib/ReactDOMInput.js +79 -108
- package/lib/ReactDOMOption.js +58 -20
- package/lib/ReactDOMSelect.js +95 -83
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +44 -69
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +20 -76
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +26 -120
- package/lib/ReactElementValidator.js +56 -192
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +3 -3
- package/lib/ReactEventEmitterMixin.js +3 -13
- package/lib/ReactEventListener.js +58 -40
- package/lib/ReactFragment.js +33 -59
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +14 -23
- package/lib/ReactInstanceHandles.js +29 -58
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +142 -285
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -15
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +7 -24
- package/lib/ReactPerf.js +8 -12
- package/lib/ReactPropTransferer.js +4 -4
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +41 -61
- package/lib/ReactReconcileTransaction.js +11 -36
- package/lib/ReactReconciler.js +14 -26
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +20 -15
- package/lib/ReactServerRenderingTransaction.js +9 -34
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +137 -190
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +69 -107
- package/lib/ReactUpdates.js +26 -81
- package/lib/ReactWithAddons.js +5 -6
- package/lib/SVGDOMPropertyConfig.js +39 -4
- package/lib/SelectEventPlugin.js +31 -33
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +138 -130
- package/lib/SyntheticClipboardEvent.js +5 -9
- package/lib/SyntheticCompositionEvent.js +4 -10
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +14 -15
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +4 -10
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +10 -16
- package/lib/SyntheticTouchEvent.js +3 -3
- package/lib/SyntheticUIEvent.js +5 -5
- package/lib/SyntheticWheelEvent.js +13 -17
- package/lib/Transaction.js +22 -28
- package/lib/ViewportMetrics.js +2 -2
- package/lib/accumulateInto.js +2 -5
- package/lib/adler32.js +2 -4
- package/lib/camelize.js +4 -2
- package/lib/camelizeStyleName.js +2 -2
- package/lib/cloneWithProps.js +6 -12
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/deprecated.js +47 -0
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +7 -27
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +3 -3
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +18 -40
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getTextContentAccessor.js +2 -4
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +3 -1
- package/lib/hyphenateStyleName.js +2 -2
- package/lib/instantiateReactComponent.js +23 -43
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +3 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +3 -3
- package/lib/keyMirror.js +3 -6
- package/lib/keyOf.js +4 -3
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +2 -2
- package/lib/onlyChild.js +2 -5
- package/lib/performance.js +2 -5
- package/lib/performanceNow.js +3 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +16 -0
- package/lib/setInnerHTML.js +11 -8
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +24 -0
- package/lib/shallowEqual.js +17 -11
- package/lib/shouldUpdateReactComponent.js +3 -64
- package/lib/toArray.js +8 -19
- package/lib/traverseAllChildren.js +23 -90
- package/lib/update.js +25 -85
- package/lib/validateDOMNesting.js +363 -0
- package/lib/warning.js +15 -17
- package/package.json +3 -3
- package/react.js +53 -1
- package/lib/LocalEventTrapMixin.js +0 -53
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactContext.js +0 -74
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/createFullPageComponent.js +0 -58
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
package/lib/isEventSupported.js
CHANGED
|
@@ -15,12 +15,10 @@ var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
15
15
|
|
|
16
16
|
var useHasFeature;
|
|
17
17
|
if (ExecutionEnvironment.canUseDOM) {
|
|
18
|
-
useHasFeature =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
|
|
23
|
-
document.implementation.hasFeature('', '') !== true;
|
|
18
|
+
useHasFeature = document.implementation && document.implementation.hasFeature &&
|
|
19
|
+
// always returns true in newer browsers as per the standard.
|
|
20
|
+
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
|
|
21
|
+
document.implementation.hasFeature('', '') !== true;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
/**
|
|
@@ -38,13 +36,12 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
38
36
|
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
39
37
|
*/
|
|
40
38
|
function isEventSupported(eventNameSuffix, capture) {
|
|
41
|
-
if (!ExecutionEnvironment.canUseDOM ||
|
|
42
|
-
capture && !('addEventListener' in document)) {
|
|
39
|
+
if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) {
|
|
43
40
|
return false;
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
var eventName = 'on' + eventNameSuffix;
|
|
47
|
-
var isSupported = eventName in document;
|
|
44
|
+
var isSupported = (eventName in document);
|
|
48
45
|
|
|
49
46
|
if (!isSupported) {
|
|
50
47
|
var element = document.createElement('div');
|
|
@@ -60,4 +57,4 @@ function isEventSupported(eventNameSuffix, capture) {
|
|
|
60
57
|
return isSupported;
|
|
61
58
|
}
|
|
62
59
|
|
|
63
|
-
module.exports = isEventSupported;
|
|
60
|
+
module.exports = isEventSupported;
|
package/lib/isNode.js
CHANGED
|
@@ -14,12 +14,10 @@
|
|
|
14
14
|
* @param {*} object The object to check.
|
|
15
15
|
* @return {boolean} Whether or not the object is a DOM node.
|
|
16
16
|
*/
|
|
17
|
+
'use strict';
|
|
18
|
+
|
|
17
19
|
function isNode(object) {
|
|
18
|
-
return !!(object && (
|
|
19
|
-
((typeof Node === 'function' ? object instanceof Node : typeof object === 'object' &&
|
|
20
|
-
typeof object.nodeType === 'number' &&
|
|
21
|
-
typeof object.nodeName === 'string'))
|
|
22
|
-
));
|
|
20
|
+
return !!(object && (typeof Node === 'function' ? object instanceof Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
module.exports = isNode;
|
|
23
|
+
module.exports = isNode;
|
|
@@ -33,9 +33,8 @@ var supportedInputTypes = {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
function isTextInputElement(elem) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
36
|
+
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
|
37
|
+
return nodeName && (nodeName === 'input' && supportedInputTypes[elem.type] || nodeName === 'textarea');
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
module.exports = isTextInputElement;
|
|
40
|
+
module.exports = isTextInputElement;
|
package/lib/isTextNode.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* @typechecks
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
13
15
|
var isNode = require("./isNode");
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -20,4 +22,4 @@ function isTextNode(object) {
|
|
|
20
22
|
return isNode(object) && object.nodeType == 3;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
module.exports = isTextNode;
|
|
25
|
+
module.exports = isTextNode;
|
package/lib/joinClasses.js
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
* Combines multiple className strings into one.
|
|
17
17
|
* http://jsperf.com/joinclasses-args-vs-array
|
|
18
18
|
*
|
|
19
|
-
* @param {...?string}
|
|
19
|
+
* @param {...?string} className
|
|
20
20
|
* @return {string}
|
|
21
21
|
*/
|
|
22
|
-
function joinClasses(className/*, ... */) {
|
|
22
|
+
function joinClasses(className /*, ... */) {
|
|
23
23
|
if (!className) {
|
|
24
24
|
className = '';
|
|
25
25
|
}
|
|
@@ -36,4 +36,4 @@ function joinClasses(className/*, ... */) {
|
|
|
36
36
|
return className;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
module.exports = joinClasses;
|
|
39
|
+
module.exports = joinClasses;
|
package/lib/keyMirror.js
CHANGED
|
@@ -32,13 +32,10 @@ var invariant = require("./invariant");
|
|
|
32
32
|
* @param {object} obj
|
|
33
33
|
* @return {object}
|
|
34
34
|
*/
|
|
35
|
-
var keyMirror = function(obj) {
|
|
35
|
+
var keyMirror = function (obj) {
|
|
36
36
|
var ret = {};
|
|
37
37
|
var key;
|
|
38
|
-
(
|
|
39
|
-
obj instanceof Object && !Array.isArray(obj),
|
|
40
|
-
'keyMirror(...): Argument must be an object.'
|
|
41
|
-
) : invariant(obj instanceof Object && !Array.isArray(obj)));
|
|
38
|
+
!(obj instanceof Object && !Array.isArray(obj)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'keyMirror(...): Argument must be an object.') : invariant(false) : undefined;
|
|
42
39
|
for (key in obj) {
|
|
43
40
|
if (!obj.hasOwnProperty(key)) {
|
|
44
41
|
continue;
|
|
@@ -48,4 +45,4 @@ var keyMirror = function(obj) {
|
|
|
48
45
|
return ret;
|
|
49
46
|
};
|
|
50
47
|
|
|
51
|
-
module.exports = keyMirror;
|
|
48
|
+
module.exports = keyMirror;
|
package/lib/keyOf.js
CHANGED
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
* 'xa12' in that case. Resolve keys you want to use once at startup time, then
|
|
20
20
|
* reuse those resolutions.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
"use strict";
|
|
23
|
+
|
|
24
|
+
var keyOf = function (oneKeyObj) {
|
|
23
25
|
var key;
|
|
24
26
|
for (key in oneKeyObj) {
|
|
25
27
|
if (!oneKeyObj.hasOwnProperty(key)) {
|
|
@@ -30,5 +32,4 @@ var keyOf = function(oneKeyObj) {
|
|
|
30
32
|
return null;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
module.exports = keyOf;
|
|
35
|
+
module.exports = keyOf;
|
package/lib/mapObject.js
CHANGED
package/lib/memoizeStringOnly.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
function memoizeStringOnly(callback) {
|
|
22
22
|
var cache = {};
|
|
23
|
-
return function(string) {
|
|
23
|
+
return function (string) {
|
|
24
24
|
if (!cache.hasOwnProperty(string)) {
|
|
25
25
|
cache[string] = callback.call(this, string);
|
|
26
26
|
}
|
|
@@ -28,4 +28,4 @@ function memoizeStringOnly(callback) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
module.exports = memoizeStringOnly;
|
|
31
|
+
module.exports = memoizeStringOnly;
|
package/lib/onlyChild.js
CHANGED
|
@@ -26,11 +26,8 @@ var invariant = require("./invariant");
|
|
|
26
26
|
* structure.
|
|
27
27
|
*/
|
|
28
28
|
function onlyChild(children) {
|
|
29
|
-
(
|
|
30
|
-
ReactElement.isValidElement(children),
|
|
31
|
-
'onlyChild must be passed a children with exactly one child.'
|
|
32
|
-
) : invariant(ReactElement.isValidElement(children)));
|
|
29
|
+
!ReactElement.isValidElement(children) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) : undefined;
|
|
33
30
|
return children;
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
module.exports = onlyChild;
|
|
33
|
+
module.exports = onlyChild;
|
package/lib/performance.js
CHANGED
|
@@ -17,10 +17,7 @@ var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
17
17
|
var performance;
|
|
18
18
|
|
|
19
19
|
if (ExecutionEnvironment.canUseDOM) {
|
|
20
|
-
performance =
|
|
21
|
-
window.performance ||
|
|
22
|
-
window.msPerformance ||
|
|
23
|
-
window.webkitPerformance;
|
|
20
|
+
performance = window.performance || window.msPerformance || window.webkitPerformance;
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
module.exports = performance || {};
|
|
23
|
+
module.exports = performance || {};
|
package/lib/performanceNow.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* @typechecks
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
13
15
|
var performance = require("./performance");
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -23,4 +25,4 @@ if (!performance || !performance.now) {
|
|
|
23
25
|
|
|
24
26
|
var performanceNow = performance.now.bind(performance);
|
|
25
27
|
|
|
26
|
-
module.exports = performanceNow;
|
|
28
|
+
module.exports = performanceNow;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2015, 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 renderSubtreeIntoContainer
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactMount = require("./ReactMount");
|
|
15
|
+
|
|
16
|
+
module.exports = ReactMount.renderSubtreeIntoContainer;
|
package/lib/setInnerHTML.js
CHANGED
|
@@ -26,14 +26,14 @@ var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
|
|
|
26
26
|
* @param {string} html
|
|
27
27
|
* @internal
|
|
28
28
|
*/
|
|
29
|
-
var setInnerHTML = function(node, html) {
|
|
29
|
+
var setInnerHTML = function (node, html) {
|
|
30
30
|
node.innerHTML = html;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// Win8 apps: Allow all html to be inserted
|
|
34
34
|
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
|
|
35
|
-
setInnerHTML = function(node, html) {
|
|
36
|
-
MSApp.execUnsafeLocalFunction(function() {
|
|
35
|
+
setInnerHTML = function (node, html) {
|
|
36
|
+
MSApp.execUnsafeLocalFunction(function () {
|
|
37
37
|
node.innerHTML = html;
|
|
38
38
|
});
|
|
39
39
|
};
|
|
@@ -49,7 +49,7 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
49
49
|
var testElement = document.createElement('div');
|
|
50
50
|
testElement.innerHTML = ' ';
|
|
51
51
|
if (testElement.innerHTML === '') {
|
|
52
|
-
setInnerHTML = function(node, html) {
|
|
52
|
+
setInnerHTML = function (node, html) {
|
|
53
53
|
// Magic theory: IE8 supposedly differentiates between added and updated
|
|
54
54
|
// nodes when processing innerHTML, innerHTML on updated nodes suffers
|
|
55
55
|
// from worse whitespace behavior. Re-adding a node like this triggers
|
|
@@ -63,11 +63,14 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
63
63
|
// thin air on IE8, this only happens if there is no visible text
|
|
64
64
|
// in-front of the non-visible tags. Piggyback on the whitespace fix
|
|
65
65
|
// and simply check if any non-visible tags appear in the source.
|
|
66
|
-
if (WHITESPACE_TEST.test(html) ||
|
|
67
|
-
html[0] === '<' && NONVISIBLE_TEST.test(html)) {
|
|
66
|
+
if (WHITESPACE_TEST.test(html) || html[0] === '<' && NONVISIBLE_TEST.test(html)) {
|
|
68
67
|
// Recover leading whitespace by temporarily prepending any character.
|
|
69
68
|
// \uFEFF has the potential advantage of being zero-width/invisible.
|
|
70
|
-
|
|
69
|
+
// UglifyJS drops U+FEFF chars when parsing, so use String.fromCharCode
|
|
70
|
+
// in hopes that this is preserved even if "\uFEFF" is transformed to
|
|
71
|
+
// the actual Unicode character (by Babel, for example).
|
|
72
|
+
// https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216
|
|
73
|
+
node.innerHTML = String.fromCharCode(0xFEFF) + html;
|
|
71
74
|
|
|
72
75
|
// deleteData leaves an empty `TextNode` which offsets the index of all
|
|
73
76
|
// children. Definitely want to avoid this.
|
|
@@ -84,4 +87,4 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
module.exports = setInnerHTML;
|
|
90
|
+
module.exports = setInnerHTML;
|
package/lib/setTextContent.js
CHANGED
|
@@ -25,16 +25,16 @@ var setInnerHTML = require("./setInnerHTML");
|
|
|
25
25
|
* @param {string} text
|
|
26
26
|
* @internal
|
|
27
27
|
*/
|
|
28
|
-
var setTextContent = function(node, text) {
|
|
28
|
+
var setTextContent = function (node, text) {
|
|
29
29
|
node.textContent = text;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
if (ExecutionEnvironment.canUseDOM) {
|
|
33
33
|
if (!('textContent' in document.documentElement)) {
|
|
34
|
-
setTextContent = function(node, text) {
|
|
34
|
+
setTextContent = function (node, text) {
|
|
35
35
|
setInnerHTML(node, escapeTextContentForBrowser(text));
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
module.exports = setTextContent;
|
|
40
|
+
module.exports = setTextContent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2015, 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 shallowCompare
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var shallowEqual = require("./shallowEqual");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Does a shallow comparison for props and state.
|
|
18
|
+
* See ReactComponentWithPureRenderMixin
|
|
19
|
+
*/
|
|
20
|
+
function shallowCompare(instance, nextProps, nextState) {
|
|
21
|
+
return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = shallowCompare;
|
package/lib/shallowEqual.js
CHANGED
|
@@ -22,21 +22,27 @@ function shallowEqual(objA, objB) {
|
|
|
22
22
|
if (objA === objB) {
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
|
|
26
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var keysA = Object.keys(objA);
|
|
31
|
+
var keysB = Object.keys(objB);
|
|
32
|
+
|
|
33
|
+
if (keysA.length !== keysB.length) {
|
|
34
|
+
return false;
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
for
|
|
35
|
-
|
|
36
|
+
|
|
37
|
+
// Test for A's keys different from B.
|
|
38
|
+
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
|
|
39
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
40
|
+
if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
|
|
36
41
|
return false;
|
|
37
42
|
}
|
|
38
43
|
}
|
|
44
|
+
|
|
39
45
|
return true;
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
module.exports = shallowEqual;
|
|
48
|
+
module.exports = shallowEqual;
|
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var warning = require("./warning");
|
|
16
|
-
|
|
17
15
|
/**
|
|
18
16
|
* Given a `prevElement` and `nextElement`, determines if the existing
|
|
19
17
|
* instance should be updated as opposed to being destroyed or replaced by a new
|
|
@@ -30,71 +28,12 @@ function shouldUpdateReactComponent(prevElement, nextElement) {
|
|
|
30
28
|
var prevType = typeof prevElement;
|
|
31
29
|
var nextType = typeof nextElement;
|
|
32
30
|
if (prevType === 'string' || prevType === 'number') {
|
|
33
|
-
return
|
|
31
|
+
return nextType === 'string' || nextType === 'number';
|
|
34
32
|
} else {
|
|
35
|
-
|
|
36
|
-
prevElement.type === nextElement.type &&
|
|
37
|
-
prevElement.key === nextElement.key) {
|
|
38
|
-
var ownersMatch = prevElement._owner === nextElement._owner;
|
|
39
|
-
var prevName = null;
|
|
40
|
-
var nextName = null;
|
|
41
|
-
var nextDisplayName = null;
|
|
42
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
43
|
-
if (!ownersMatch) {
|
|
44
|
-
if (prevElement._owner != null &&
|
|
45
|
-
prevElement._owner.getPublicInstance() != null &&
|
|
46
|
-
prevElement._owner.getPublicInstance().constructor != null) {
|
|
47
|
-
prevName =
|
|
48
|
-
prevElement._owner.getPublicInstance().constructor.displayName;
|
|
49
|
-
}
|
|
50
|
-
if (nextElement._owner != null &&
|
|
51
|
-
nextElement._owner.getPublicInstance() != null &&
|
|
52
|
-
nextElement._owner.getPublicInstance().constructor != null) {
|
|
53
|
-
nextName =
|
|
54
|
-
nextElement._owner.getPublicInstance().constructor.displayName;
|
|
55
|
-
}
|
|
56
|
-
if (nextElement.type != null &&
|
|
57
|
-
nextElement.type.displayName != null) {
|
|
58
|
-
nextDisplayName = nextElement.type.displayName;
|
|
59
|
-
}
|
|
60
|
-
if (nextElement.type != null && typeof nextElement.type === 'string') {
|
|
61
|
-
nextDisplayName = nextElement.type;
|
|
62
|
-
}
|
|
63
|
-
if (typeof nextElement.type !== 'string' ||
|
|
64
|
-
nextElement.type === 'input' ||
|
|
65
|
-
nextElement.type === 'textarea') {
|
|
66
|
-
if ((prevElement._owner != null &&
|
|
67
|
-
prevElement._owner._isOwnerNecessary === false) ||
|
|
68
|
-
(nextElement._owner != null &&
|
|
69
|
-
nextElement._owner._isOwnerNecessary === false)) {
|
|
70
|
-
if (prevElement._owner != null) {
|
|
71
|
-
prevElement._owner._isOwnerNecessary = true;
|
|
72
|
-
}
|
|
73
|
-
if (nextElement._owner != null) {
|
|
74
|
-
nextElement._owner._isOwnerNecessary = true;
|
|
75
|
-
}
|
|
76
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
77
|
-
false,
|
|
78
|
-
'<%s /> is being rendered by both %s and %s using the same ' +
|
|
79
|
-
'key (%s) in the same place. Currently, this means that ' +
|
|
80
|
-
'they don\'t preserve state. This behavior should be very ' +
|
|
81
|
-
'rare so we\'re considering deprecating it. Please contact ' +
|
|
82
|
-
'the React team and explain your use case so that we can ' +
|
|
83
|
-
'take that into consideration.',
|
|
84
|
-
nextDisplayName || 'Unknown Component',
|
|
85
|
-
prevName || '[Unknown]',
|
|
86
|
-
nextName || '[Unknown]',
|
|
87
|
-
prevElement.key
|
|
88
|
-
) : null);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return ownersMatch;
|
|
94
|
-
}
|
|
33
|
+
return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
|
|
95
34
|
}
|
|
96
35
|
}
|
|
97
36
|
return false;
|
|
98
37
|
}
|
|
99
38
|
|
|
100
|
-
module.exports = shouldUpdateReactComponent;
|
|
39
|
+
module.exports = shouldUpdateReactComponent;
|