react-test-renderer 15.5.0 → 15.5.4
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/lib/ReactShallowRenderer.js +6 -0
- package/lib/shallow/ARIADOMPropertyConfig.js +73 -0
- package/lib/shallow/AutoFocusUtils.js +23 -0
- package/lib/shallow/BeforeInputEventPlugin.js +384 -0
- package/lib/shallow/CSSProperty.js +147 -0
- package/lib/shallow/CSSPropertyOperations.js +208 -0
- package/lib/shallow/CallbackQueue.js +118 -0
- package/lib/shallow/ChangeEventPlugin.js +345 -0
- package/lib/shallow/DOMChildrenOperations.js +224 -0
- package/lib/shallow/DOMLazyTree.js +117 -0
- package/lib/shallow/DOMNamespaces.js +19 -0
- package/lib/shallow/DOMProperty.js +209 -0
- package/lib/shallow/DOMPropertyOperations.js +236 -0
- package/lib/shallow/Danger.js +47 -0
- package/lib/shallow/DefaultEventPluginOrder.js +25 -0
- package/lib/shallow/EnterLeaveEventPlugin.js +99 -0
- package/lib/shallow/EventConstants.js +91 -0
- package/lib/shallow/EventPluginHub.js +277 -0
- package/lib/shallow/EventPluginRegistry.js +254 -0
- package/lib/shallow/EventPluginUtils.js +225 -0
- package/lib/shallow/EventPropagators.js +133 -0
- package/lib/shallow/FallbackCompositionState.js +94 -0
- package/lib/shallow/HTMLDOMPropertyConfig.js +235 -0
- package/lib/shallow/KeyEscapeUtils.js +58 -0
- package/lib/shallow/LinkedValueUtils.js +137 -0
- package/lib/shallow/PluginModuleType.js +12 -0
- package/lib/shallow/PooledClass.js +111 -0
- package/lib/shallow/ReactBrowserEventEmitter.js +327 -0
- package/lib/shallow/ReactChildFiber.js +243 -0
- package/lib/shallow/ReactChildReconciler.js +153 -0
- package/lib/shallow/ReactComponentBrowserEnvironment.js +29 -0
- package/lib/shallow/ReactComponentEnvironment.js +45 -0
- package/lib/shallow/ReactCompositeComponent.js +901 -0
- package/lib/shallow/ReactCoroutine.js +80 -0
- package/lib/shallow/ReactDOM.js +110 -0
- package/lib/shallow/ReactDOMComponent.js +1000 -0
- package/lib/shallow/ReactDOMComponentFlags.js +17 -0
- package/lib/shallow/ReactDOMComponentTree.js +194 -0
- package/lib/shallow/ReactDOMContainerInfo.js +32 -0
- package/lib/shallow/ReactDOMEmptyComponent.js +59 -0
- package/lib/shallow/ReactDOMFeatureFlags.js +18 -0
- package/lib/shallow/ReactDOMFiber.js +97 -0
- package/lib/shallow/ReactDOMIDOperations.js +33 -0
- package/lib/shallow/ReactDOMInput.js +284 -0
- package/lib/shallow/ReactDOMInvalidARIAHook.js +92 -0
- package/lib/shallow/ReactDOMNullInputValuePropHook.js +42 -0
- package/lib/shallow/ReactDOMOption.js +122 -0
- package/lib/shallow/ReactDOMSelect.js +199 -0
- package/lib/shallow/ReactDOMSelection.js +211 -0
- package/lib/shallow/ReactDOMServer.js +25 -0
- package/lib/shallow/ReactDOMTextComponent.js +163 -0
- package/lib/shallow/ReactDOMTextarea.js +159 -0
- package/lib/shallow/ReactDOMTreeTraversal.js +135 -0
- package/lib/shallow/ReactDOMUnknownPropertyHook.js +111 -0
- package/lib/shallow/ReactDebugTool.js +358 -0
- package/lib/shallow/ReactDefaultBatchingStrategy.js +67 -0
- package/lib/shallow/ReactDefaultInjection.js +85 -0
- package/lib/shallow/ReactElementSymbol.js +19 -0
- package/lib/shallow/ReactEmptyComponent.js +29 -0
- package/lib/shallow/ReactErrorUtils.js +75 -0
- package/lib/shallow/ReactEventEmitterMixin.js +32 -0
- package/lib/shallow/ReactEventListener.js +154 -0
- package/lib/shallow/ReactFeatureFlags.js +21 -0
- package/lib/shallow/ReactFiber.js +190 -0
- package/lib/shallow/ReactFiberBeginWork.js +380 -0
- package/lib/shallow/ReactFiberCommitWork.js +78 -0
- package/lib/shallow/ReactFiberCompleteWork.js +208 -0
- package/lib/shallow/ReactFiberReconciler.js +64 -0
- package/lib/shallow/ReactFiberRoot.js +29 -0
- package/lib/shallow/ReactFiberScheduler.js +331 -0
- package/lib/shallow/ReactFiberUpdateQueue.js +77 -0
- package/lib/shallow/ReactHostComponent.js +67 -0
- package/lib/shallow/ReactHostOperationHistoryHook.js +33 -0
- package/lib/shallow/ReactInjection.js +33 -0
- package/lib/shallow/ReactInputSelection.js +123 -0
- package/lib/shallow/ReactInstanceMap.js +47 -0
- package/lib/shallow/ReactInstanceType.js +12 -0
- package/lib/shallow/ReactInstrumentation.js +23 -0
- package/lib/shallow/ReactInvalidSetStateWarningHook.js +36 -0
- package/lib/shallow/ReactMarkupChecksum.js +49 -0
- package/lib/shallow/ReactMount.js +537 -0
- package/lib/shallow/ReactMultiChild.js +449 -0
- package/lib/shallow/ReactMultiChildUpdateTypes.js +18 -0
- package/lib/shallow/ReactNodeTypes.js +39 -0
- package/lib/shallow/ReactOwner.js +93 -0
- package/lib/shallow/ReactPerf.js +500 -0
- package/lib/shallow/ReactPriorityLevel.js +20 -0
- package/lib/shallow/ReactPropTypeLocationNames.js +24 -0
- package/lib/shallow/ReactPropTypeLocations.js +12 -0
- package/lib/shallow/ReactPropTypesSecret.js +16 -0
- package/lib/shallow/ReactReconcileTransaction.js +177 -0
- package/lib/shallow/ReactReconciler.js +167 -0
- package/lib/shallow/ReactRef.js +88 -0
- package/lib/shallow/ReactReifiedYield.js +30 -0
- package/lib/shallow/ReactServerBatchingStrategy.js +21 -0
- package/lib/shallow/ReactServerRendering.js +89 -0
- package/lib/shallow/ReactServerRenderingTransaction.js +89 -0
- package/lib/shallow/ReactServerUpdateQueue.js +138 -0
- package/lib/shallow/ReactShallowRenderer.js +150 -0
- package/lib/shallow/ReactSimpleEmptyComponent.js +36 -0
- package/lib/shallow/ReactSyntheticEventType.js +14 -0
- package/lib/shallow/ReactTestEmptyComponent.js +36 -0
- package/lib/shallow/ReactTestMount.js +131 -0
- package/lib/shallow/ReactTestReconcileTransaction.js +128 -0
- package/lib/shallow/ReactTestRenderer.js +139 -0
- package/lib/shallow/ReactTestTextComponent.js +40 -0
- package/lib/shallow/ReactTypeOfWork.js +23 -0
- package/lib/shallow/ReactTypes.js +12 -0
- package/lib/shallow/ReactUpdateQueue.js +235 -0
- package/lib/shallow/ReactUpdates.js +250 -0
- package/lib/shallow/ReactVersion.js +13 -0
- package/lib/shallow/ResponderEventPlugin.js +507 -0
- package/lib/shallow/ResponderSyntheticEvent.js +38 -0
- package/lib/shallow/ResponderTouchHistoryStore.js +183 -0
- package/lib/shallow/SVGDOMPropertyConfig.js +301 -0
- package/lib/shallow/SelectEventPlugin.js +190 -0
- package/lib/shallow/SimpleEventPlugin.js +227 -0
- package/lib/shallow/SyntheticAnimationEvent.js +38 -0
- package/lib/shallow/SyntheticClipboardEvent.js +37 -0
- package/lib/shallow/SyntheticCompositionEvent.js +35 -0
- package/lib/shallow/SyntheticDragEvent.js +35 -0
- package/lib/shallow/SyntheticEvent.js +267 -0
- package/lib/shallow/SyntheticFocusEvent.js +35 -0
- package/lib/shallow/SyntheticInputEvent.js +36 -0
- package/lib/shallow/SyntheticKeyboardEvent.js +83 -0
- package/lib/shallow/SyntheticMouseEvent.js +71 -0
- package/lib/shallow/SyntheticTouchEvent.js +44 -0
- package/lib/shallow/SyntheticTransitionEvent.js +38 -0
- package/lib/shallow/SyntheticUIEvent.js +58 -0
- package/lib/shallow/SyntheticWheelEvent.js +53 -0
- package/lib/shallow/TapEventPlugin.js +115 -0
- package/lib/shallow/TouchHistoryMath.js +98 -0
- package/lib/shallow/Transaction.js +224 -0
- package/lib/shallow/ViewportMetrics.js +26 -0
- package/lib/shallow/accumulate.js +45 -0
- package/lib/shallow/accumulateInto.js +57 -0
- package/lib/shallow/adler32.js +43 -0
- package/lib/shallow/canDefineProperty.js +25 -0
- package/lib/shallow/checkReactTypeSpec.js +86 -0
- package/lib/shallow/createMicrosoftUnsafeLocalFunction.js +31 -0
- package/lib/shallow/dangerousStyleValue.js +78 -0
- package/lib/shallow/deprecated.js +56 -0
- package/lib/shallow/escapeTextContentForBrowser.js +122 -0
- package/lib/shallow/findDOMNode.js +59 -0
- package/lib/shallow/flattenChildren.js +75 -0
- package/lib/shallow/forEachAccumulated.js +30 -0
- package/lib/shallow/getEventCharCode.js +49 -0
- package/lib/shallow/getEventKey.js +101 -0
- package/lib/shallow/getEventModifierState.js +42 -0
- package/lib/shallow/getEventTarget.js +34 -0
- package/lib/shallow/getHostComponentFromComposite.js +29 -0
- package/lib/shallow/getIteratorFn.js +40 -0
- package/lib/shallow/getNodeForCharacterOffset.js +73 -0
- package/lib/shallow/getTextContentAccessor.js +32 -0
- package/lib/shallow/getVendorPrefixedEventName.js +100 -0
- package/lib/shallow/instantiateReactComponent.js +128 -0
- package/lib/shallow/isEventSupported.js +59 -0
- package/lib/shallow/isTextInputElement.js +50 -0
- package/lib/shallow/quoteAttributeValueForBrowser.js +25 -0
- package/lib/shallow/reactProdInvariant.js +38 -0
- package/lib/shallow/renderSubtreeIntoContainer.js +15 -0
- package/lib/shallow/setInnerHTML.js +97 -0
- package/lib/shallow/setTextContent.js +51 -0
- package/lib/shallow/shouldUpdateReactComponent.js +41 -0
- package/lib/shallow/traverseAllChildren.js +175 -0
- package/lib/shallow/validateDOMNesting.js +376 -0
- package/package.json +1 -1
- package/shallow.js +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generate a mapping of standard vendor prefixes using the defined style property and event name.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} styleProp
|
|
19
|
+
* @param {string} eventName
|
|
20
|
+
* @returns {object}
|
|
21
|
+
*/
|
|
22
|
+
function makePrefixMap(styleProp, eventName) {
|
|
23
|
+
var prefixes = {};
|
|
24
|
+
|
|
25
|
+
prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
|
|
26
|
+
prefixes['Webkit' + styleProp] = 'webkit' + eventName;
|
|
27
|
+
prefixes['Moz' + styleProp] = 'moz' + eventName;
|
|
28
|
+
prefixes['ms' + styleProp] = 'MS' + eventName;
|
|
29
|
+
prefixes['O' + styleProp] = 'o' + eventName.toLowerCase();
|
|
30
|
+
|
|
31
|
+
return prefixes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A list of event names to a configurable list of vendor prefixes.
|
|
36
|
+
*/
|
|
37
|
+
var vendorPrefixes = {
|
|
38
|
+
animationend: makePrefixMap('Animation', 'AnimationEnd'),
|
|
39
|
+
animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
|
|
40
|
+
animationstart: makePrefixMap('Animation', 'AnimationStart'),
|
|
41
|
+
transitionend: makePrefixMap('Transition', 'TransitionEnd')
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Event names that have already been detected and prefixed (if applicable).
|
|
46
|
+
*/
|
|
47
|
+
var prefixedEventNames = {};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Element to check for prefixes on.
|
|
51
|
+
*/
|
|
52
|
+
var style = {};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Bootstrap if a DOM exists.
|
|
56
|
+
*/
|
|
57
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
58
|
+
style = document.createElement('div').style;
|
|
59
|
+
|
|
60
|
+
// On some platforms, in particular some releases of Android 4.x,
|
|
61
|
+
// the un-prefixed "animation" and "transition" properties are defined on the
|
|
62
|
+
// style object but the events that fire will still be prefixed, so we need
|
|
63
|
+
// to check if the un-prefixed events are usable, and if not remove them from the map.
|
|
64
|
+
if (!('AnimationEvent' in window)) {
|
|
65
|
+
delete vendorPrefixes.animationend.animation;
|
|
66
|
+
delete vendorPrefixes.animationiteration.animation;
|
|
67
|
+
delete vendorPrefixes.animationstart.animation;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Same as above
|
|
71
|
+
if (!('TransitionEvent' in window)) {
|
|
72
|
+
delete vendorPrefixes.transitionend.transition;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Attempts to determine the correct vendor prefixed event name.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} eventName
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
function getVendorPrefixedEventName(eventName) {
|
|
83
|
+
if (prefixedEventNames[eventName]) {
|
|
84
|
+
return prefixedEventNames[eventName];
|
|
85
|
+
} else if (!vendorPrefixes[eventName]) {
|
|
86
|
+
return eventName;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var prefixMap = vendorPrefixes[eventName];
|
|
90
|
+
|
|
91
|
+
for (var styleProp in prefixMap) {
|
|
92
|
+
if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
|
|
93
|
+
return prefixedEventNames[eventName] = prefixMap[styleProp];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = getVendorPrefixedEventName;
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var _prodInvariant = require('./reactProdInvariant'),
|
|
14
|
+
_assign = require('object-assign');
|
|
15
|
+
|
|
16
|
+
var ReactCompositeComponent = require('./ReactCompositeComponent');
|
|
17
|
+
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
18
|
+
var ReactHostComponent = require('./ReactHostComponent');
|
|
19
|
+
|
|
20
|
+
var getNextDebugID = require('react/lib/getNextDebugID');
|
|
21
|
+
var invariant = require('fbjs/lib/invariant');
|
|
22
|
+
var warning = require('fbjs/lib/warning');
|
|
23
|
+
|
|
24
|
+
// To avoid a cyclic dependency, we create the final class in this module
|
|
25
|
+
var ReactCompositeComponentWrapper = function (element) {
|
|
26
|
+
this.construct(element);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function getDeclarationErrorAddendum(owner) {
|
|
30
|
+
if (owner) {
|
|
31
|
+
var name = owner.getName();
|
|
32
|
+
if (name) {
|
|
33
|
+
return ' Check the render method of `' + name + '`.';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Check if the type reference is a known internal type. I.e. not a user
|
|
41
|
+
* provided composite type.
|
|
42
|
+
*
|
|
43
|
+
* @param {function} type
|
|
44
|
+
* @return {boolean} Returns true if this is a valid internal type.
|
|
45
|
+
*/
|
|
46
|
+
function isInternalComponentType(type) {
|
|
47
|
+
return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Given a ReactNode, create an instance that will actually be mounted.
|
|
52
|
+
*
|
|
53
|
+
* @param {ReactNode} node
|
|
54
|
+
* @param {boolean} shouldHaveDebugID
|
|
55
|
+
* @return {object} A new instance of the element's constructor.
|
|
56
|
+
* @protected
|
|
57
|
+
*/
|
|
58
|
+
function instantiateReactComponent(node, shouldHaveDebugID) {
|
|
59
|
+
var instance;
|
|
60
|
+
|
|
61
|
+
if (node === null || node === false) {
|
|
62
|
+
instance = ReactEmptyComponent.create(instantiateReactComponent);
|
|
63
|
+
} else if (typeof node === 'object') {
|
|
64
|
+
var element = node;
|
|
65
|
+
var type = element.type;
|
|
66
|
+
if (typeof type !== 'function' && typeof type !== 'string') {
|
|
67
|
+
var info = '';
|
|
68
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
69
|
+
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
70
|
+
info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
info += getDeclarationErrorAddendum(element._owner);
|
|
74
|
+
!false ? 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', type == null ? type : typeof type, info) : _prodInvariant('130', type == null ? type : typeof type, info) : void 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Special case string values
|
|
78
|
+
if (typeof element.type === 'string') {
|
|
79
|
+
instance = ReactHostComponent.createInternalComponent(element);
|
|
80
|
+
} else if (isInternalComponentType(element.type)) {
|
|
81
|
+
// This is temporarily available for custom components that are not string
|
|
82
|
+
// representations. I.e. ART. Once those are updated to use the string
|
|
83
|
+
// representation, we can drop this code path.
|
|
84
|
+
instance = new element.type(element);
|
|
85
|
+
|
|
86
|
+
// We renamed this. Allow the old name for compat. :(
|
|
87
|
+
if (!instance.getHostNode) {
|
|
88
|
+
instance.getHostNode = instance.getNativeNode;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
instance = new ReactCompositeComponentWrapper(element);
|
|
92
|
+
}
|
|
93
|
+
} else if (typeof node === 'string' || typeof node === 'number') {
|
|
94
|
+
instance = ReactHostComponent.createInstanceForText(node);
|
|
95
|
+
} else {
|
|
96
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : _prodInvariant('131', typeof node) : void 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
100
|
+
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;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// These two fields are used by the DOM and ART diffing algorithms
|
|
104
|
+
// respectively. Instead of using expandos on components, we should be
|
|
105
|
+
// storing the state needed by the diffing algorithms elsewhere.
|
|
106
|
+
instance._mountIndex = 0;
|
|
107
|
+
instance._mountImage = null;
|
|
108
|
+
|
|
109
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
110
|
+
instance._debugID = shouldHaveDebugID ? getNextDebugID() : 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Internal instances should fully constructed at this point, so they should
|
|
114
|
+
// not get any new fields added to them at this point.
|
|
115
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
116
|
+
if (Object.preventExtensions) {
|
|
117
|
+
Object.preventExtensions(instance);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return instance;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
_assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent, {
|
|
125
|
+
_instantiateReactComponent: instantiateReactComponent
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
module.exports = instantiateReactComponent;
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
14
|
+
|
|
15
|
+
var useHasFeature;
|
|
16
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
17
|
+
useHasFeature = document.implementation && document.implementation.hasFeature &&
|
|
18
|
+
// always returns true in newer browsers as per the standard.
|
|
19
|
+
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
|
|
20
|
+
document.implementation.hasFeature('', '') !== true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Checks if an event is supported in the current execution environment.
|
|
25
|
+
*
|
|
26
|
+
* NOTE: This will not work correctly for non-generic events such as `change`,
|
|
27
|
+
* `reset`, `load`, `error`, and `select`.
|
|
28
|
+
*
|
|
29
|
+
* Borrows from Modernizr.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} eventNameSuffix Event name, e.g. "click".
|
|
32
|
+
* @param {?boolean} capture Check if the capture phase is supported.
|
|
33
|
+
* @return {boolean} True if the event is supported.
|
|
34
|
+
* @internal
|
|
35
|
+
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
36
|
+
*/
|
|
37
|
+
function isEventSupported(eventNameSuffix, capture) {
|
|
38
|
+
if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var eventName = 'on' + eventNameSuffix;
|
|
43
|
+
var isSupported = eventName in document;
|
|
44
|
+
|
|
45
|
+
if (!isSupported) {
|
|
46
|
+
var element = document.createElement('div');
|
|
47
|
+
element.setAttribute(eventName, 'return;');
|
|
48
|
+
isSupported = typeof element[eventName] === 'function';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
|
|
52
|
+
// This is the only way to test support for the `wheel` event in IE9+.
|
|
53
|
+
isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return isSupported;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = isEventSupported;
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
var supportedInputTypes = {
|
|
19
|
+
'color': true,
|
|
20
|
+
'date': true,
|
|
21
|
+
'datetime': true,
|
|
22
|
+
'datetime-local': true,
|
|
23
|
+
'email': true,
|
|
24
|
+
'month': true,
|
|
25
|
+
'number': true,
|
|
26
|
+
'password': true,
|
|
27
|
+
'range': true,
|
|
28
|
+
'search': true,
|
|
29
|
+
'tel': true,
|
|
30
|
+
'text': true,
|
|
31
|
+
'time': true,
|
|
32
|
+
'url': true,
|
|
33
|
+
'week': true
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function isTextInputElement(elem) {
|
|
37
|
+
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
|
38
|
+
|
|
39
|
+
if (nodeName === 'input') {
|
|
40
|
+
return !!supportedInputTypes[elem.type];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (nodeName === 'textarea') {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = isTextInputElement;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Escapes attribute value to prevent scripting attacks.
|
|
17
|
+
*
|
|
18
|
+
* @param {*} value Value to escape.
|
|
19
|
+
* @return {string} An escaped string.
|
|
20
|
+
*/
|
|
21
|
+
function quoteAttributeValueForBrowser(value) {
|
|
22
|
+
return '"' + escapeTextContentForBrowser(value) + '"';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = quoteAttributeValueForBrowser;
|
|
@@ -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
|
+
*
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var ReactMount = require('./ReactMount');
|
|
14
|
+
|
|
15
|
+
module.exports = ReactMount.renderSubtreeIntoContainer;
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
14
|
+
var DOMNamespaces = require('./DOMNamespaces');
|
|
15
|
+
|
|
16
|
+
var WHITESPACE_TEST = /^[ \r\n\t\f]/;
|
|
17
|
+
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
|
|
18
|
+
|
|
19
|
+
var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction');
|
|
20
|
+
|
|
21
|
+
// SVG temp container for IE lacking innerHTML
|
|
22
|
+
var reusableSVGContainer;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Set the innerHTML property of a node, ensuring that whitespace is preserved
|
|
26
|
+
* even in IE8.
|
|
27
|
+
*
|
|
28
|
+
* @param {DOMElement} node
|
|
29
|
+
* @param {string} html
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
|
|
33
|
+
// IE does not have innerHTML for SVG nodes, so instead we inject the
|
|
34
|
+
// new markup in a temp node and then move the child nodes across into
|
|
35
|
+
// the target node
|
|
36
|
+
if (node.namespaceURI === DOMNamespaces.svg && !('innerHTML' in node)) {
|
|
37
|
+
reusableSVGContainer = reusableSVGContainer || document.createElement('div');
|
|
38
|
+
reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>';
|
|
39
|
+
var svgNode = reusableSVGContainer.firstChild;
|
|
40
|
+
while (svgNode.firstChild) {
|
|
41
|
+
node.appendChild(svgNode.firstChild);
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
node.innerHTML = html;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
49
|
+
// IE8: When updating a just created node with innerHTML only leading
|
|
50
|
+
// whitespace is removed. When updating an existing node with innerHTML
|
|
51
|
+
// whitespace in root TextNodes is also collapsed.
|
|
52
|
+
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
|
|
53
|
+
|
|
54
|
+
// Feature detection; only IE8 is known to behave improperly like this.
|
|
55
|
+
var testElement = document.createElement('div');
|
|
56
|
+
testElement.innerHTML = ' ';
|
|
57
|
+
if (testElement.innerHTML === '') {
|
|
58
|
+
setInnerHTML = function (node, html) {
|
|
59
|
+
// Magic theory: IE8 supposedly differentiates between added and updated
|
|
60
|
+
// nodes when processing innerHTML, innerHTML on updated nodes suffers
|
|
61
|
+
// from worse whitespace behavior. Re-adding a node like this triggers
|
|
62
|
+
// the initial and more favorable whitespace behavior.
|
|
63
|
+
// TODO: What to do on a detached node?
|
|
64
|
+
if (node.parentNode) {
|
|
65
|
+
node.parentNode.replaceChild(node, node);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// We also implement a workaround for non-visible tags disappearing into
|
|
69
|
+
// thin air on IE8, this only happens if there is no visible text
|
|
70
|
+
// in-front of the non-visible tags. Piggyback on the whitespace fix
|
|
71
|
+
// and simply check if any non-visible tags appear in the source.
|
|
72
|
+
if (WHITESPACE_TEST.test(html) || html[0] === '<' && NONVISIBLE_TEST.test(html)) {
|
|
73
|
+
// Recover leading whitespace by temporarily prepending any character.
|
|
74
|
+
// \uFEFF has the potential advantage of being zero-width/invisible.
|
|
75
|
+
// UglifyJS drops U+FEFF chars when parsing, so use String.fromCharCode
|
|
76
|
+
// in hopes that this is preserved even if "\uFEFF" is transformed to
|
|
77
|
+
// the actual Unicode character (by Babel, for example).
|
|
78
|
+
// https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216
|
|
79
|
+
node.innerHTML = String.fromCharCode(0xFEFF) + html;
|
|
80
|
+
|
|
81
|
+
// deleteData leaves an empty `TextNode` which offsets the index of all
|
|
82
|
+
// children. Definitely want to avoid this.
|
|
83
|
+
var textNode = node.firstChild;
|
|
84
|
+
if (textNode.data.length === 1) {
|
|
85
|
+
node.removeChild(textNode);
|
|
86
|
+
} else {
|
|
87
|
+
textNode.deleteData(0, 1);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
node.innerHTML = html;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
testElement = null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = setInnerHTML;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
14
|
+
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
|
|
15
|
+
var setInnerHTML = require('./setInnerHTML');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Set the textContent property of a node, ensuring that whitespace is preserved
|
|
19
|
+
* even in IE8. innerText is a poor substitute for textContent and, among many
|
|
20
|
+
* issues, inserts <br> instead of the literal newline chars. innerHTML behaves
|
|
21
|
+
* as it should.
|
|
22
|
+
*
|
|
23
|
+
* @param {DOMElement} node
|
|
24
|
+
* @param {string} text
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
var setTextContent = function (node, text) {
|
|
28
|
+
if (text) {
|
|
29
|
+
var firstChild = node.firstChild;
|
|
30
|
+
|
|
31
|
+
if (firstChild && firstChild === node.lastChild && firstChild.nodeType === 3) {
|
|
32
|
+
firstChild.nodeValue = text;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
node.textContent = text;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
40
|
+
if (!('textContent' in document.documentElement)) {
|
|
41
|
+
setTextContent = function (node, text) {
|
|
42
|
+
if (node.nodeType === 3) {
|
|
43
|
+
node.nodeValue = text;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
setInnerHTML(node, escapeTextContentForBrowser(text));
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = setTextContent;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Given a `prevElement` and `nextElement`, determines if the existing
|
|
15
|
+
* instance should be updated as opposed to being destroyed or replaced by a new
|
|
16
|
+
* instance. Both arguments are elements. This ensures that this logic can
|
|
17
|
+
* operate on stateless trees without any backing instance.
|
|
18
|
+
*
|
|
19
|
+
* @param {?object} prevElement
|
|
20
|
+
* @param {?object} nextElement
|
|
21
|
+
* @return {boolean} True if the existing instance should be updated.
|
|
22
|
+
* @protected
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
function shouldUpdateReactComponent(prevElement, nextElement) {
|
|
26
|
+
var prevEmpty = prevElement === null || prevElement === false;
|
|
27
|
+
var nextEmpty = nextElement === null || nextElement === false;
|
|
28
|
+
if (prevEmpty || nextEmpty) {
|
|
29
|
+
return prevEmpty === nextEmpty;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var prevType = typeof prevElement;
|
|
33
|
+
var nextType = typeof nextElement;
|
|
34
|
+
if (prevType === 'string' || prevType === 'number') {
|
|
35
|
+
return nextType === 'string' || nextType === 'number';
|
|
36
|
+
} else {
|
|
37
|
+
return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = shouldUpdateReactComponent;
|