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/ReactFragment.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
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 ReactFragment
|
|
10
|
-
*/
|
|
9
|
+
* @providesModule ReactFragment
|
|
10
|
+
*/
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
@@ -23,53 +23,41 @@ var warning = require("./warning");
|
|
|
23
23
|
* create a keyed fragment. The resulting data structure is opaque, for now.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
var fragmentKey;
|
|
27
|
+
var didWarnKey;
|
|
28
|
+
var canWarnForReactFragment;
|
|
29
|
+
|
|
30
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
31
|
+
fragmentKey = '_reactFragment';
|
|
32
|
+
didWarnKey = '_reactDidWarn';
|
|
30
33
|
|
|
31
34
|
try {
|
|
32
35
|
// Feature test. Don't even try to issue this warning if we can't use
|
|
33
36
|
// enumerable: false.
|
|
34
37
|
|
|
35
|
-
var dummy = function() {
|
|
38
|
+
var dummy = function () {
|
|
36
39
|
return 1;
|
|
37
40
|
};
|
|
38
41
|
|
|
39
|
-
Object.defineProperty(
|
|
40
|
-
{},
|
|
41
|
-
fragmentKey,
|
|
42
|
-
{enumerable: false, value: true}
|
|
43
|
-
);
|
|
42
|
+
Object.defineProperty({}, fragmentKey, { enumerable: false, value: true });
|
|
44
43
|
|
|
45
|
-
Object.defineProperty(
|
|
46
|
-
{},
|
|
47
|
-
'key',
|
|
48
|
-
{enumerable: true, get: dummy}
|
|
49
|
-
);
|
|
44
|
+
Object.defineProperty({}, 'key', { enumerable: true, get: dummy });
|
|
50
45
|
|
|
51
46
|
canWarnForReactFragment = true;
|
|
52
|
-
} catch (x) {
|
|
47
|
+
} catch (x) {
|
|
48
|
+
canWarnForReactFragment = false;
|
|
49
|
+
}
|
|
53
50
|
|
|
54
|
-
var proxyPropertyAccessWithWarning = function(obj, key) {
|
|
51
|
+
var proxyPropertyAccessWithWarning = function (obj, key) {
|
|
55
52
|
Object.defineProperty(obj, key, {
|
|
56
53
|
enumerable: true,
|
|
57
|
-
get: function() {
|
|
58
|
-
|
|
59
|
-
this[didWarnKey],
|
|
60
|
-
'A ReactFragment is an opaque type. Accessing any of its ' +
|
|
61
|
-
'properties is deprecated. Pass it to one of the React.Children ' +
|
|
62
|
-
'helpers.'
|
|
63
|
-
) : null);
|
|
54
|
+
get: function () {
|
|
55
|
+
'production' !== process.env.NODE_ENV ? warning(this[didWarnKey], 'A ReactFragment is an opaque type. Accessing any of its ' + 'properties is deprecated. Pass it to one of the React.Children ' + 'helpers.') : undefined;
|
|
64
56
|
this[didWarnKey] = true;
|
|
65
57
|
return this[fragmentKey][key];
|
|
66
58
|
},
|
|
67
|
-
set: function(value) {
|
|
68
|
-
|
|
69
|
-
this[didWarnKey],
|
|
70
|
-
'A ReactFragment is an immutable opaque type. Mutating its ' +
|
|
71
|
-
'properties is deprecated.'
|
|
72
|
-
) : null);
|
|
59
|
+
set: function (value) {
|
|
60
|
+
'production' !== process.env.NODE_ENV ? warning(this[didWarnKey], 'A ReactFragment is an immutable opaque type. Mutating its ' + 'properties is deprecated.') : undefined;
|
|
73
61
|
this[didWarnKey] = true;
|
|
74
62
|
this[fragmentKey][key] = value;
|
|
75
63
|
}
|
|
@@ -78,12 +66,12 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
78
66
|
|
|
79
67
|
var issuedWarnings = {};
|
|
80
68
|
|
|
81
|
-
var didWarnForFragment = function(fragment) {
|
|
69
|
+
var didWarnForFragment = function (fragment) {
|
|
82
70
|
// We use the keys and the type of the value as a heuristic to dedupe the
|
|
83
71
|
// warning to avoid spamming too much.
|
|
84
72
|
var fragmentCacheKey = '';
|
|
85
73
|
for (var key in fragment) {
|
|
86
|
-
fragmentCacheKey += key + ':' +
|
|
74
|
+
fragmentCacheKey += key + ':' + typeof fragment[key] + ',';
|
|
87
75
|
}
|
|
88
76
|
var alreadyWarnedOnce = !!issuedWarnings[fragmentCacheKey];
|
|
89
77
|
issuedWarnings[fragmentCacheKey] = true;
|
|
@@ -94,22 +82,14 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
94
82
|
var ReactFragment = {
|
|
95
83
|
// Wrap a keyed object in an opaque proxy that warns you if you access any
|
|
96
84
|
// of its properties.
|
|
97
|
-
create: function(object) {
|
|
98
|
-
if (
|
|
85
|
+
create: function (object) {
|
|
86
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
99
87
|
if (typeof object !== 'object' || !object || Array.isArray(object)) {
|
|
100
|
-
|
|
101
|
-
false,
|
|
102
|
-
'React.addons.createFragment only accepts a single object.',
|
|
103
|
-
object
|
|
104
|
-
) : null);
|
|
88
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : undefined;
|
|
105
89
|
return object;
|
|
106
90
|
}
|
|
107
91
|
if (ReactElement.isValidElement(object)) {
|
|
108
|
-
|
|
109
|
-
false,
|
|
110
|
-
'React.addons.createFragment does not accept a ReactElement ' +
|
|
111
|
-
'without a wrapper object.'
|
|
112
|
-
) : null);
|
|
92
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') : undefined;
|
|
113
93
|
return object;
|
|
114
94
|
}
|
|
115
95
|
if (canWarnForReactFragment) {
|
|
@@ -134,16 +114,11 @@ var ReactFragment = {
|
|
|
134
114
|
},
|
|
135
115
|
// Extract the original keyed object from the fragment opaque type. Warn if
|
|
136
116
|
// a plain object is passed here.
|
|
137
|
-
extract: function(fragment) {
|
|
138
|
-
if (
|
|
117
|
+
extract: function (fragment) {
|
|
118
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
139
119
|
if (canWarnForReactFragment) {
|
|
140
120
|
if (!fragment[fragmentKey]) {
|
|
141
|
-
|
|
142
|
-
didWarnForFragment(fragment),
|
|
143
|
-
'Any use of a keyed object should be wrapped in ' +
|
|
144
|
-
'React.addons.createFragment(object) before being passed as a ' +
|
|
145
|
-
'child.'
|
|
146
|
-
) : null);
|
|
121
|
+
'production' !== process.env.NODE_ENV ? warning(didWarnForFragment(fragment), 'Any use of a keyed object should be wrapped in ' + 'React.addons.createFragment(object) before being passed as a ' + 'child.') : undefined;
|
|
147
122
|
return fragment;
|
|
148
123
|
}
|
|
149
124
|
return fragment[fragmentKey];
|
|
@@ -154,8 +129,8 @@ var ReactFragment = {
|
|
|
154
129
|
// Check if this is a fragment and if so, extract the keyed object. If it
|
|
155
130
|
// is a fragment-like object, warn that it should be wrapped. Ignore if we
|
|
156
131
|
// can't determine what kind of object this is.
|
|
157
|
-
extractIfFragment: function(fragment) {
|
|
158
|
-
if (
|
|
132
|
+
extractIfFragment: function (fragment) {
|
|
133
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
159
134
|
if (canWarnForReactFragment) {
|
|
160
135
|
// If it is the opaque type, return the keyed object.
|
|
161
136
|
if (fragment[fragmentKey]) {
|
|
@@ -165,8 +140,7 @@ var ReactFragment = {
|
|
|
165
140
|
// it is probably meant as a fragment, so we can warn early. Defer,
|
|
166
141
|
// the warning to extract.
|
|
167
142
|
for (var key in fragment) {
|
|
168
|
-
if (fragment.hasOwnProperty(key) &&
|
|
169
|
-
ReactElement.isValidElement(fragment[key])) {
|
|
143
|
+
if (fragment.hasOwnProperty(key) && ReactElement.isValidElement(fragment[key])) {
|
|
170
144
|
// This looks like a fragment object, we should provide an
|
|
171
145
|
// early warning.
|
|
172
146
|
return ReactFragment.extract(fragment);
|
|
@@ -178,4 +152,4 @@ var ReactFragment = {
|
|
|
178
152
|
}
|
|
179
153
|
};
|
|
180
154
|
|
|
181
|
-
module.exports = ReactFragment;
|
|
155
|
+
module.exports = ReactFragment;
|
package/lib/ReactInjection.js
CHANGED
|
@@ -29,21 +29,16 @@ function isInDocument(node) {
|
|
|
29
29
|
*/
|
|
30
30
|
var ReactInputSelection = {
|
|
31
31
|
|
|
32
|
-
hasSelectionCapabilities: function(elem) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
elem.nodeName === 'TEXTAREA' || elem.contentEditable === 'true')
|
|
36
|
-
);
|
|
32
|
+
hasSelectionCapabilities: function (elem) {
|
|
33
|
+
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
|
34
|
+
return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true');
|
|
37
35
|
},
|
|
38
36
|
|
|
39
|
-
getSelectionInformation: function() {
|
|
37
|
+
getSelectionInformation: function () {
|
|
40
38
|
var focusedElem = getActiveElement();
|
|
41
39
|
return {
|
|
42
40
|
focusedElem: focusedElem,
|
|
43
|
-
selectionRange:
|
|
44
|
-
ReactInputSelection.hasSelectionCapabilities(focusedElem) ?
|
|
45
|
-
ReactInputSelection.getSelection(focusedElem) :
|
|
46
|
-
null
|
|
41
|
+
selectionRange: ReactInputSelection.hasSelectionCapabilities(focusedElem) ? ReactInputSelection.getSelection(focusedElem) : null
|
|
47
42
|
};
|
|
48
43
|
},
|
|
49
44
|
|
|
@@ -52,17 +47,13 @@ var ReactInputSelection = {
|
|
|
52
47
|
* restore it. This is useful when performing operations that could remove dom
|
|
53
48
|
* nodes and place them back in, resulting in focus being lost.
|
|
54
49
|
*/
|
|
55
|
-
restoreSelection: function(priorSelectionInformation) {
|
|
50
|
+
restoreSelection: function (priorSelectionInformation) {
|
|
56
51
|
var curFocusedElem = getActiveElement();
|
|
57
52
|
var priorFocusedElem = priorSelectionInformation.focusedElem;
|
|
58
53
|
var priorSelectionRange = priorSelectionInformation.selectionRange;
|
|
59
|
-
if (curFocusedElem !== priorFocusedElem &&
|
|
60
|
-
isInDocument(priorFocusedElem)) {
|
|
54
|
+
if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
|
|
61
55
|
if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
|
|
62
|
-
ReactInputSelection.setSelection(
|
|
63
|
-
priorFocusedElem,
|
|
64
|
-
priorSelectionRange
|
|
65
|
-
);
|
|
56
|
+
ReactInputSelection.setSelection(priorFocusedElem, priorSelectionRange);
|
|
66
57
|
}
|
|
67
58
|
focusNode(priorFocusedElem);
|
|
68
59
|
}
|
|
@@ -74,7 +65,7 @@ var ReactInputSelection = {
|
|
|
74
65
|
* -@input: Look up selection bounds of this input
|
|
75
66
|
* -@return {start: selectionStart, end: selectionEnd}
|
|
76
67
|
*/
|
|
77
|
-
getSelection: function(input) {
|
|
68
|
+
getSelection: function (input) {
|
|
78
69
|
var selection;
|
|
79
70
|
|
|
80
71
|
if ('selectionStart' in input) {
|
|
@@ -83,7 +74,7 @@ var ReactInputSelection = {
|
|
|
83
74
|
start: input.selectionStart,
|
|
84
75
|
end: input.selectionEnd
|
|
85
76
|
};
|
|
86
|
-
} else if (document.selection && input.nodeName === '
|
|
77
|
+
} else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
|
|
87
78
|
// IE8 input.
|
|
88
79
|
var range = document.selection.createRange();
|
|
89
80
|
// There can only be one selection per document in IE, so it must
|
|
@@ -99,7 +90,7 @@ var ReactInputSelection = {
|
|
|
99
90
|
selection = ReactDOMSelection.getOffsets(input);
|
|
100
91
|
}
|
|
101
92
|
|
|
102
|
-
return selection || {start: 0, end: 0};
|
|
93
|
+
return selection || { start: 0, end: 0 };
|
|
103
94
|
},
|
|
104
95
|
|
|
105
96
|
/**
|
|
@@ -108,7 +99,7 @@ var ReactInputSelection = {
|
|
|
108
99
|
* -@input Set selection bounds of this input or textarea
|
|
109
100
|
* -@offsets Object of same form that is returned from get*
|
|
110
101
|
*/
|
|
111
|
-
setSelection: function(input, offsets) {
|
|
102
|
+
setSelection: function (input, offsets) {
|
|
112
103
|
var start = offsets.start;
|
|
113
104
|
var end = offsets.end;
|
|
114
105
|
if (typeof end === 'undefined') {
|
|
@@ -118,7 +109,7 @@ var ReactInputSelection = {
|
|
|
118
109
|
if ('selectionStart' in input) {
|
|
119
110
|
input.selectionStart = start;
|
|
120
111
|
input.selectionEnd = Math.min(end, input.value.length);
|
|
121
|
-
} else if (document.selection && input.nodeName === '
|
|
112
|
+
} else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
|
|
122
113
|
var range = input.createTextRange();
|
|
123
114
|
range.collapse(true);
|
|
124
115
|
range.moveStart('character', start);
|
|
@@ -130,4 +121,4 @@ var ReactInputSelection = {
|
|
|
130
121
|
}
|
|
131
122
|
};
|
|
132
123
|
|
|
133
|
-
module.exports = ReactInputSelection;
|
|
124
|
+
module.exports = ReactInputSelection;
|
|
@@ -22,7 +22,7 @@ var SEPARATOR_LENGTH = SEPARATOR.length;
|
|
|
22
22
|
/**
|
|
23
23
|
* Maximum depth of traversals before we consider the possibility of a bad ID.
|
|
24
24
|
*/
|
|
25
|
-
var MAX_TREE_DEPTH =
|
|
25
|
+
var MAX_TREE_DEPTH = 10000;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Creates a DOM ID prefix to use when mounting React components.
|
|
@@ -55,9 +55,7 @@ function isBoundary(id, index) {
|
|
|
55
55
|
* @private
|
|
56
56
|
*/
|
|
57
57
|
function isValidID(id) {
|
|
58
|
-
return id === '' || (
|
|
59
|
-
id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR
|
|
60
|
-
);
|
|
58
|
+
return id === '' || id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR;
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
/**
|
|
@@ -69,10 +67,7 @@ function isValidID(id) {
|
|
|
69
67
|
* @internal
|
|
70
68
|
*/
|
|
71
69
|
function isAncestorIDOf(ancestorID, descendantID) {
|
|
72
|
-
return (
|
|
73
|
-
descendantID.indexOf(ancestorID) === 0 &&
|
|
74
|
-
isBoundary(descendantID, ancestorID.length)
|
|
75
|
-
);
|
|
70
|
+
return descendantID.indexOf(ancestorID) === 0 && isBoundary(descendantID, ancestorID.length);
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
/**
|
|
@@ -96,19 +91,8 @@ function getParentID(id) {
|
|
|
96
91
|
* @private
|
|
97
92
|
*/
|
|
98
93
|
function getNextDescendantID(ancestorID, destinationID) {
|
|
99
|
-
(
|
|
100
|
-
|
|
101
|
-
'getNextDescendantID(%s, %s): Received an invalid React DOM ID.',
|
|
102
|
-
ancestorID,
|
|
103
|
-
destinationID
|
|
104
|
-
) : invariant(isValidID(ancestorID) && isValidID(destinationID)));
|
|
105
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
106
|
-
isAncestorIDOf(ancestorID, destinationID),
|
|
107
|
-
'getNextDescendantID(...): React has made an invalid assumption about ' +
|
|
108
|
-
'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.',
|
|
109
|
-
ancestorID,
|
|
110
|
-
destinationID
|
|
111
|
-
) : invariant(isAncestorIDOf(ancestorID, destinationID)));
|
|
94
|
+
!(isValidID(ancestorID) && isValidID(destinationID)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : undefined;
|
|
95
|
+
!isAncestorIDOf(ancestorID, destinationID) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : undefined;
|
|
112
96
|
if (ancestorID === destinationID) {
|
|
113
97
|
return ancestorID;
|
|
114
98
|
}
|
|
@@ -150,13 +134,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
150
134
|
}
|
|
151
135
|
}
|
|
152
136
|
var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
|
|
153
|
-
(
|
|
154
|
-
isValidID(longestCommonID),
|
|
155
|
-
'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s',
|
|
156
|
-
oneID,
|
|
157
|
-
twoID,
|
|
158
|
-
longestCommonID
|
|
159
|
-
) : invariant(isValidID(longestCommonID)));
|
|
137
|
+
!isValidID(longestCommonID) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : undefined;
|
|
160
138
|
return longestCommonID;
|
|
161
139
|
}
|
|
162
140
|
|
|
@@ -168,6 +146,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
168
146
|
* @param {?string} start ID at which to start traversal.
|
|
169
147
|
* @param {?string} stop ID at which to end traversal.
|
|
170
148
|
* @param {function} cb Callback to invoke each ID with.
|
|
149
|
+
* @param {*} arg Argument to invoke the callback with.
|
|
171
150
|
* @param {?boolean} skipFirst Whether or not to skip the first node.
|
|
172
151
|
* @param {?boolean} skipLast Whether or not to skip the last node.
|
|
173
152
|
* @private
|
|
@@ -175,23 +154,13 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
175
154
|
function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
176
155
|
start = start || '';
|
|
177
156
|
stop = stop || '';
|
|
178
|
-
(
|
|
179
|
-
start !== stop,
|
|
180
|
-
'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.',
|
|
181
|
-
start
|
|
182
|
-
) : invariant(start !== stop));
|
|
157
|
+
!(start !== stop) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : undefined;
|
|
183
158
|
var traverseUp = isAncestorIDOf(stop, start);
|
|
184
|
-
(
|
|
185
|
-
traverseUp || isAncestorIDOf(start, stop),
|
|
186
|
-
'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' +
|
|
187
|
-
'not have a parent path.',
|
|
188
|
-
start,
|
|
189
|
-
stop
|
|
190
|
-
) : invariant(traverseUp || isAncestorIDOf(start, stop)));
|
|
159
|
+
!(traverseUp || isAncestorIDOf(start, stop)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : undefined;
|
|
191
160
|
// Traverse from `start` to `stop` one depth at a time.
|
|
192
161
|
var depth = 0;
|
|
193
162
|
var traverse = traverseUp ? getParentID : getNextDescendantID;
|
|
194
|
-
for (var id = start
|
|
163
|
+
for (var id = start;; id = traverse(id, stop)) {
|
|
195
164
|
var ret;
|
|
196
165
|
if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
|
|
197
166
|
ret = cb(id, traverseUp, arg);
|
|
@@ -200,12 +169,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
|
200
169
|
// Only break //after// visiting `stop`.
|
|
201
170
|
break;
|
|
202
171
|
}
|
|
203
|
-
(
|
|
204
|
-
depth++ < MAX_TREE_DEPTH,
|
|
205
|
-
'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' +
|
|
206
|
-
'traversing the React DOM ID tree. This may be due to malformed IDs: %s',
|
|
207
|
-
start, stop
|
|
208
|
-
) : invariant(depth++ < MAX_TREE_DEPTH));
|
|
172
|
+
!(depth++ < MAX_TREE_DEPTH) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : undefined;
|
|
209
173
|
}
|
|
210
174
|
}
|
|
211
175
|
|
|
@@ -222,7 +186,7 @@ var ReactInstanceHandles = {
|
|
|
222
186
|
* Constructs a React root ID
|
|
223
187
|
* @return {string} A React root ID.
|
|
224
188
|
*/
|
|
225
|
-
createReactRootID: function() {
|
|
189
|
+
createReactRootID: function () {
|
|
226
190
|
return getReactRootIDString(ReactRootIndex.createReactRootIndex());
|
|
227
191
|
},
|
|
228
192
|
|
|
@@ -234,7 +198,7 @@ var ReactInstanceHandles = {
|
|
|
234
198
|
* @return {string} A React ID.
|
|
235
199
|
* @internal
|
|
236
200
|
*/
|
|
237
|
-
createReactID: function(rootID, name) {
|
|
201
|
+
createReactID: function (rootID, name) {
|
|
238
202
|
return rootID + name;
|
|
239
203
|
},
|
|
240
204
|
|
|
@@ -246,7 +210,7 @@ var ReactInstanceHandles = {
|
|
|
246
210
|
* @return {?string} DOM ID of the React component that is the root.
|
|
247
211
|
* @internal
|
|
248
212
|
*/
|
|
249
|
-
getReactRootIDFromNodeID: function(id) {
|
|
213
|
+
getReactRootIDFromNodeID: function (id) {
|
|
250
214
|
if (id && id.charAt(0) === SEPARATOR && id.length > 1) {
|
|
251
215
|
var index = id.indexOf(SEPARATOR, 1);
|
|
252
216
|
return index > -1 ? id.substr(0, index) : id;
|
|
@@ -268,7 +232,7 @@ var ReactInstanceHandles = {
|
|
|
268
232
|
* @param {*} downArg Argument to invoke the callback with on entered IDs.
|
|
269
233
|
* @internal
|
|
270
234
|
*/
|
|
271
|
-
traverseEnterLeave: function(leaveID, enterID, cb, upArg, downArg) {
|
|
235
|
+
traverseEnterLeave: function (leaveID, enterID, cb, upArg, downArg) {
|
|
272
236
|
var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
|
|
273
237
|
if (ancestorID !== leaveID) {
|
|
274
238
|
traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
|
|
@@ -288,13 +252,23 @@ var ReactInstanceHandles = {
|
|
|
288
252
|
* @param {*} arg Argument to invoke the callback with.
|
|
289
253
|
* @internal
|
|
290
254
|
*/
|
|
291
|
-
traverseTwoPhase: function(targetID, cb, arg) {
|
|
255
|
+
traverseTwoPhase: function (targetID, cb, arg) {
|
|
292
256
|
if (targetID) {
|
|
293
257
|
traverseParentPath('', targetID, cb, arg, true, false);
|
|
294
258
|
traverseParentPath(targetID, '', cb, arg, false, true);
|
|
295
259
|
}
|
|
296
260
|
},
|
|
297
261
|
|
|
262
|
+
/**
|
|
263
|
+
* Same as `traverseTwoPhase` but skips the `targetID`.
|
|
264
|
+
*/
|
|
265
|
+
traverseTwoPhaseSkipTarget: function (targetID, cb, arg) {
|
|
266
|
+
if (targetID) {
|
|
267
|
+
traverseParentPath('', targetID, cb, arg, true, true);
|
|
268
|
+
traverseParentPath(targetID, '', cb, arg, true, true);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
|
|
298
272
|
/**
|
|
299
273
|
* Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
|
|
300
274
|
* example, passing `.0.$row-0.1` would result in `cb` getting called
|
|
@@ -307,15 +281,11 @@ var ReactInstanceHandles = {
|
|
|
307
281
|
* @param {*} arg Argument to invoke the callback with.
|
|
308
282
|
* @internal
|
|
309
283
|
*/
|
|
310
|
-
traverseAncestors: function(targetID, cb, arg) {
|
|
284
|
+
traverseAncestors: function (targetID, cb, arg) {
|
|
311
285
|
traverseParentPath('', targetID, cb, arg, true, false);
|
|
312
286
|
},
|
|
313
287
|
|
|
314
|
-
|
|
315
|
-
* Exposed for unit testing.
|
|
316
|
-
* @private
|
|
317
|
-
*/
|
|
318
|
-
_getFirstCommonAncestorID: getFirstCommonAncestorID,
|
|
288
|
+
getFirstCommonAncestorID: getFirstCommonAncestorID,
|
|
319
289
|
|
|
320
290
|
/**
|
|
321
291
|
* Exposed for unit testing.
|
|
@@ -330,3 +300,4 @@ var ReactInstanceHandles = {
|
|
|
330
300
|
};
|
|
331
301
|
|
|
332
302
|
module.exports = ReactInstanceHandles;
|
|
303
|
+
/* until break */
|