react 0.14.0-alpha3 → 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 +2 -2
- package/dist/JSXTransformer.js +69 -70
- package/dist/react-with-addons.js +2047 -2078
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +1861 -1904
- package/dist/react.min.js +5 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +13 -3
- package/lib/ChangeEventPlugin.js +4 -2
- package/lib/DOMProperty.js +81 -116
- package/lib/DOMPropertyOperations.js +70 -25
- package/lib/EnterLeaveEventPlugin.js +3 -3
- package/lib/EventPluginHub.js +2 -2
- package/lib/EventPluginUtils.js +6 -6
- package/lib/HTMLDOMPropertyConfig.js +8 -1
- package/lib/LinkedValueUtils.js +45 -33
- package/lib/PooledClass.js +12 -0
- package/lib/React.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +8 -0
- package/lib/ReactChildren.js +3 -3
- package/lib/ReactClass.js +29 -47
- package/lib/ReactComponent.js +11 -6
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +45 -72
- package/lib/ReactDOM.js +1 -0
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMClient.js +9 -4
- package/lib/ReactDOMComponent.js +302 -24
- package/lib/ReactDOMIDOperations.js +14 -0
- package/lib/ReactDOMInput.js +78 -94
- package/lib/ReactDOMOption.js +19 -38
- package/lib/ReactDOMSelect.js +85 -95
- package/lib/ReactDOMTextarea.js +39 -52
- package/lib/ReactDefaultInjection.js +0 -47
- package/lib/ReactElement.js +18 -79
- package/lib/ReactElementValidator.js +29 -98
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +2 -3
- package/lib/ReactEventListener.js +43 -3
- package/lib/ReactFragment.js +12 -7
- package/lib/ReactInputSelection.js +4 -3
- package/lib/ReactInstanceHandles.js +3 -2
- package/lib/ReactMount.js +20 -40
- package/lib/ReactNativeComponent.js +0 -5
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactPropTypes.js +3 -3
- package/lib/ReactReconcileTransaction.js +2 -2
- package/lib/ReactReconciler.js +8 -10
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +13 -0
- package/lib/ReactServerRenderingTransaction.js +2 -2
- package/lib/ReactTestUtils.js +56 -33
- package/lib/ReactUpdateQueue.js +51 -26
- package/lib/ReactUpdates.js +0 -3
- package/lib/ReactWithAddons.js +0 -2
- package/lib/SelectEventPlugin.js +6 -7
- package/lib/SimpleEventPlugin.js +4 -4
- package/lib/SyntheticClipboardEvent.js +2 -2
- package/lib/SyntheticCompositionEvent.js +2 -2
- package/lib/SyntheticDragEvent.js +2 -2
- package/lib/SyntheticEvent.js +6 -5
- package/lib/SyntheticFocusEvent.js +2 -2
- package/lib/SyntheticInputEvent.js +2 -2
- package/lib/SyntheticKeyboardEvent.js +2 -2
- package/lib/SyntheticMouseEvent.js +2 -2
- package/lib/SyntheticTouchEvent.js +2 -2
- package/lib/SyntheticUIEvent.js +2 -2
- package/lib/SyntheticWheelEvent.js +2 -2
- package/lib/Transaction.js +10 -4
- package/lib/cloneWithProps.js +1 -1
- package/lib/deprecated.js +47 -0
- package/lib/findDOMNode.js +2 -3
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getMarkupWrap.js +13 -35
- package/lib/instantiateReactComponent.js +13 -9
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/setInnerHTML.js +1 -1
- package/lib/traverseAllChildren.js +1 -1
- package/lib/warning.js +0 -4
- package/package.json +1 -1
- package/react.js +53 -1
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- 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/createFullPageComponent.js +0 -51
package/lib/ReactErrorUtils.js
CHANGED
|
@@ -29,9 +29,8 @@ var ReactEventEmitterMixin = {
|
|
|
29
29
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
30
30
|
* @param {object} nativeEvent Native environment event.
|
|
31
31
|
*/
|
|
32
|
-
handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
|
|
33
|
-
var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent);
|
|
34
|
-
|
|
32
|
+
handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
|
33
|
+
var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
|
|
35
34
|
runEventQueueInBatch(events);
|
|
36
35
|
}
|
|
37
36
|
};
|
|
@@ -23,6 +23,8 @@ var assign = require("./Object.assign");
|
|
|
23
23
|
var getEventTarget = require("./getEventTarget");
|
|
24
24
|
var getUnboundedScrollPosition = require("./getUnboundedScrollPosition");
|
|
25
25
|
|
|
26
|
+
var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
* Finds the parent React component of `node`.
|
|
28
30
|
*
|
|
@@ -57,6 +59,17 @@ assign(TopLevelCallbackBookKeeping.prototype, {
|
|
|
57
59
|
PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
|
|
58
60
|
|
|
59
61
|
function handleTopLevelImpl(bookKeeping) {
|
|
62
|
+
if (bookKeeping.nativeEvent.path) {
|
|
63
|
+
// New browsers have a path attribute on native events
|
|
64
|
+
handleTopLevelWithPath(bookKeeping);
|
|
65
|
+
} else {
|
|
66
|
+
// Legacy browsers don't have a path attribute on native events
|
|
67
|
+
handleTopLevelWithoutPath(bookKeeping);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Legacy browsers don't have a path attribute on native events
|
|
72
|
+
function handleTopLevelWithoutPath(bookKeeping) {
|
|
60
73
|
var topLevelTarget = ReactMount.getFirstReactDOM(getEventTarget(bookKeeping.nativeEvent)) || window;
|
|
61
74
|
|
|
62
75
|
// Loop through the hierarchy, in case there's any nested components.
|
|
@@ -72,7 +85,34 @@ function handleTopLevelImpl(bookKeeping) {
|
|
|
72
85
|
for (var i = 0; i < bookKeeping.ancestors.length; i++) {
|
|
73
86
|
topLevelTarget = bookKeeping.ancestors[i];
|
|
74
87
|
var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
|
|
75
|
-
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent);
|
|
88
|
+
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// New browsers have a path attribute on native events
|
|
93
|
+
function handleTopLevelWithPath(bookKeeping) {
|
|
94
|
+
var path = bookKeeping.nativeEvent.path;
|
|
95
|
+
var currentNativeTarget = path[0];
|
|
96
|
+
for (var i = 0; i < path.length; i++) {
|
|
97
|
+
var currentPathElement = path[i];
|
|
98
|
+
var currentPathElemenId = ReactMount.getID(currentPathElement);
|
|
99
|
+
if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
|
|
100
|
+
currentNativeTarget = path[i + 1];
|
|
101
|
+
}
|
|
102
|
+
if (ReactMount.isRenderedByReact(currentPathElement)) {
|
|
103
|
+
var newRootId = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElemenId);
|
|
104
|
+
bookKeeping.ancestors.push(currentPathElement);
|
|
105
|
+
|
|
106
|
+
var topLevelTargetID = ReactMount.getID(currentPathElement) || '';
|
|
107
|
+
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, currentPathElement, topLevelTargetID, bookKeeping.nativeEvent, currentNativeTarget);
|
|
108
|
+
|
|
109
|
+
// Jump to the root of this React render tree
|
|
110
|
+
while (currentPathElemenId !== newRootId) {
|
|
111
|
+
i++;
|
|
112
|
+
currentPathElement = path[i];
|
|
113
|
+
currentPathElemenId = ReactMount.getID(currentPathElement);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
76
116
|
}
|
|
77
117
|
}
|
|
78
118
|
|
|
@@ -105,7 +145,7 @@ var ReactEventListener = {
|
|
|
105
145
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
106
146
|
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
107
147
|
* @param {object} handle Element on which to attach listener.
|
|
108
|
-
* @return {object} An object with a remove function which will forcefully
|
|
148
|
+
* @return {?object} An object with a remove function which will forcefully
|
|
109
149
|
* remove the listener.
|
|
110
150
|
* @internal
|
|
111
151
|
*/
|
|
@@ -123,7 +163,7 @@ var ReactEventListener = {
|
|
|
123
163
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
124
164
|
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
125
165
|
* @param {object} handle Element on which to attach listener.
|
|
126
|
-
* @return {object} An object with a remove function which will forcefully
|
|
166
|
+
* @return {?object} An object with a remove function which will forcefully
|
|
127
167
|
* remove the listener.
|
|
128
168
|
* @internal
|
|
129
169
|
*/
|
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,10 +23,13 @@ var warning = require("./warning");
|
|
|
23
23
|
* create a keyed fragment. The resulting data structure is opaque, for now.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
var fragmentKey;
|
|
27
|
+
var didWarnKey;
|
|
28
|
+
var canWarnForReactFragment;
|
|
29
|
+
|
|
26
30
|
if ('production' !== process.env.NODE_ENV) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var canWarnForReactFragment = false;
|
|
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
|
|
@@ -41,7 +44,9 @@ if ('production' !== process.env.NODE_ENV) {
|
|
|
41
44
|
Object.defineProperty({}, 'key', { enumerable: true, get: dummy });
|
|
42
45
|
|
|
43
46
|
canWarnForReactFragment = true;
|
|
44
|
-
} catch (x) {
|
|
47
|
+
} catch (x) {
|
|
48
|
+
canWarnForReactFragment = false;
|
|
49
|
+
}
|
|
45
50
|
|
|
46
51
|
var proxyPropertyAccessWithWarning = function (obj, key) {
|
|
47
52
|
Object.defineProperty(obj, key, {
|
|
@@ -80,7 +85,7 @@ var ReactFragment = {
|
|
|
80
85
|
create: function (object) {
|
|
81
86
|
if ('production' !== process.env.NODE_ENV) {
|
|
82
87
|
if (typeof object !== 'object' || !object || Array.isArray(object)) {
|
|
83
|
-
'production' !== process.env.NODE_ENV ? warning(false, 'React.addons.createFragment only accepts a single object.', object) : undefined;
|
|
88
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : undefined;
|
|
84
89
|
return object;
|
|
85
90
|
}
|
|
86
91
|
if (ReactElement.isValidElement(object)) {
|
|
@@ -30,7 +30,8 @@ function isInDocument(node) {
|
|
|
30
30
|
var ReactInputSelection = {
|
|
31
31
|
|
|
32
32
|
hasSelectionCapabilities: function (elem) {
|
|
33
|
-
|
|
33
|
+
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
|
34
|
+
return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true');
|
|
34
35
|
},
|
|
35
36
|
|
|
36
37
|
getSelectionInformation: function () {
|
|
@@ -73,7 +74,7 @@ var ReactInputSelection = {
|
|
|
73
74
|
start: input.selectionStart,
|
|
74
75
|
end: input.selectionEnd
|
|
75
76
|
};
|
|
76
|
-
} else if (document.selection && input.nodeName === '
|
|
77
|
+
} else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
|
|
77
78
|
// IE8 input.
|
|
78
79
|
var range = document.selection.createRange();
|
|
79
80
|
// There can only be one selection per document in IE, so it must
|
|
@@ -108,7 +109,7 @@ var ReactInputSelection = {
|
|
|
108
109
|
if ('selectionStart' in input) {
|
|
109
110
|
input.selectionStart = start;
|
|
110
111
|
input.selectionEnd = Math.min(end, input.value.length);
|
|
111
|
-
} else if (document.selection && input.nodeName === '
|
|
112
|
+
} else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
|
|
112
113
|
var range = input.createTextRange();
|
|
113
114
|
range.collapse(true);
|
|
114
115
|
range.moveStart('character', start);
|
|
@@ -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.
|
|
@@ -146,6 +146,7 @@ function getFirstCommonAncestorID(oneID, twoID) {
|
|
|
146
146
|
* @param {?string} start ID at which to start traversal.
|
|
147
147
|
* @param {?string} stop ID at which to end traversal.
|
|
148
148
|
* @param {function} cb Callback to invoke each ID with.
|
|
149
|
+
* @param {*} arg Argument to invoke the callback with.
|
|
149
150
|
* @param {?boolean} skipFirst Whether or not to skip the first node.
|
|
150
151
|
* @param {?boolean} skipLast Whether or not to skip the last node.
|
|
151
152
|
* @private
|
|
@@ -168,7 +169,7 @@ function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
|
168
169
|
// Only break //after// visiting `stop`.
|
|
169
170
|
break;
|
|
170
171
|
}
|
|
171
|
-
!(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) : invariant(false) : undefined;
|
|
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;
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
|
package/lib/ReactMount.js
CHANGED
|
@@ -15,7 +15,6 @@ var DOMProperty = require("./DOMProperty");
|
|
|
15
15
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
16
16
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
17
17
|
var ReactElement = require("./ReactElement");
|
|
18
|
-
var ReactElementValidator = require("./ReactElementValidator");
|
|
19
18
|
var ReactEmptyComponent = require("./ReactEmptyComponent");
|
|
20
19
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
21
20
|
var ReactInstanceMap = require("./ReactInstanceMap");
|
|
@@ -255,7 +254,7 @@ function mountComponentIntoNode(componentInstance, rootID, container, transactio
|
|
|
255
254
|
context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null);
|
|
256
255
|
}
|
|
257
256
|
var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);
|
|
258
|
-
componentInstance.
|
|
257
|
+
componentInstance._renderedComponent._topLevelWrapper = componentInstance;
|
|
259
258
|
ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
|
|
260
259
|
}
|
|
261
260
|
|
|
@@ -295,6 +294,17 @@ function unmountComponentFromNode(instance, container) {
|
|
|
295
294
|
}
|
|
296
295
|
}
|
|
297
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Temporary (?) hack so that we can store all top-level pending updates on
|
|
299
|
+
* composites instead of having to worry about different types of components
|
|
300
|
+
* here.
|
|
301
|
+
*/
|
|
302
|
+
var TopLevelWrapper = function () {};
|
|
303
|
+
TopLevelWrapper.prototype.render = function () {
|
|
304
|
+
// this.props is actually a ReactElement
|
|
305
|
+
return this.props;
|
|
306
|
+
};
|
|
307
|
+
|
|
298
308
|
/**
|
|
299
309
|
* Mounting is the process of initializing a React component by creating its
|
|
300
310
|
* representative DOM elements and inserting them into a supplied `container`.
|
|
@@ -337,10 +347,6 @@ var ReactMount = {
|
|
|
337
347
|
* @param {?function} callback function triggered on completion
|
|
338
348
|
*/
|
|
339
349
|
_updateRootComponent: function (prevComponent, nextElement, container, callback) {
|
|
340
|
-
if ('production' !== process.env.NODE_ENV) {
|
|
341
|
-
ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
350
|
ReactMount.scrollMonitor(container, function () {
|
|
345
351
|
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
|
|
346
352
|
if (callback) {
|
|
@@ -426,14 +432,17 @@ var ReactMount = {
|
|
|
426
432
|
// Check if it quacks like an element
|
|
427
433
|
nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : undefined;
|
|
428
434
|
|
|
429
|
-
'production' !== process.env.NODE_ENV ? warning(container
|
|
435
|
+
'production' !== process.env.NODE_ENV ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : undefined;
|
|
436
|
+
|
|
437
|
+
var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, nextElement);
|
|
430
438
|
|
|
431
439
|
var prevComponent = instancesByReactRootID[getReactRootID(container)];
|
|
432
440
|
|
|
433
441
|
if (prevComponent) {
|
|
434
|
-
var
|
|
442
|
+
var prevWrappedElement = prevComponent._currentElement;
|
|
443
|
+
var prevElement = prevWrappedElement.props;
|
|
435
444
|
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
436
|
-
return ReactMount._updateRootComponent(prevComponent,
|
|
445
|
+
return ReactMount._updateRootComponent(prevComponent, nextWrappedElement, container, callback)._renderedComponent.getPublicInstance();
|
|
437
446
|
} else {
|
|
438
447
|
ReactMount.unmountComponentAtNode(container);
|
|
439
448
|
}
|
|
@@ -457,7 +466,7 @@ var ReactMount = {
|
|
|
457
466
|
}
|
|
458
467
|
|
|
459
468
|
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
|
|
460
|
-
var component = ReactMount._renderNewRootComponent(
|
|
469
|
+
var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, parentComponent != null ? parentComponent._reactInternalInstance._processChildContext(parentComponent._reactInternalInstance._context) : emptyObject)._renderedComponent.getPublicInstance();
|
|
461
470
|
if (callback) {
|
|
462
471
|
callback.call(component);
|
|
463
472
|
}
|
|
@@ -480,35 +489,6 @@ var ReactMount = {
|
|
|
480
489
|
return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback);
|
|
481
490
|
},
|
|
482
491
|
|
|
483
|
-
/**
|
|
484
|
-
* Constructs a component instance of `constructor` with `initialProps` and
|
|
485
|
-
* renders it into the supplied `container`.
|
|
486
|
-
*
|
|
487
|
-
* @param {function} constructor React component constructor.
|
|
488
|
-
* @param {?object} props Initial props of the component instance.
|
|
489
|
-
* @param {DOMElement} container DOM element to render into.
|
|
490
|
-
* @return {ReactComponent} Component instance rendered in `container`.
|
|
491
|
-
*/
|
|
492
|
-
constructAndRenderComponent: function (constructor, props, container) {
|
|
493
|
-
var element = ReactElement.createElement(constructor, props);
|
|
494
|
-
return ReactMount.render(element, container);
|
|
495
|
-
},
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Constructs a component instance of `constructor` with `initialProps` and
|
|
499
|
-
* renders it into a container node identified by supplied `id`.
|
|
500
|
-
*
|
|
501
|
-
* @param {function} componentConstructor React component constructor
|
|
502
|
-
* @param {?object} props Initial props of the component instance.
|
|
503
|
-
* @param {string} id ID of the DOM element to render into.
|
|
504
|
-
* @return {ReactComponent} Component instance rendered in the container node.
|
|
505
|
-
*/
|
|
506
|
-
constructAndRenderComponentByID: function (constructor, props, id) {
|
|
507
|
-
var domNode = document.getElementById(id);
|
|
508
|
-
!domNode ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Tried to get element with id of "%s" but it is not present on the page.', id) : invariant(false) : undefined;
|
|
509
|
-
return ReactMount.constructAndRenderComponent(constructor, props, domNode);
|
|
510
|
-
},
|
|
511
|
-
|
|
512
492
|
/**
|
|
513
493
|
* Registers a container node into which React components will be rendered.
|
|
514
494
|
* This also creates the "reactRoot" ID that will be assigned to the element
|
|
@@ -587,7 +567,7 @@ var ReactMount = {
|
|
|
587
567
|
// warning is when the container is empty.
|
|
588
568
|
rootElementsByReactRootID[reactRootID] = containerChild;
|
|
589
569
|
} else {
|
|
590
|
-
'production' !== process.env.NODE_ENV ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container:', rootElement.parentNode) : undefined;
|
|
570
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container: %s', rootElement.parentNode) : undefined;
|
|
591
571
|
}
|
|
592
572
|
}
|
|
593
573
|
}
|
|
@@ -35,11 +35,6 @@ var ReactNativeComponentInjection = {
|
|
|
35
35
|
// tag. That particular tag will use this class instead of the generic one.
|
|
36
36
|
injectComponentClasses: function (componentClasses) {
|
|
37
37
|
assign(tagToComponentClass, componentClasses);
|
|
38
|
-
},
|
|
39
|
-
// Temporary hack since we expect DOM refs to behave like composites,
|
|
40
|
-
// for this release.
|
|
41
|
-
injectAutoWrapper: function (wrapperFactory) {
|
|
42
|
-
autoGenerateWrapperClass = wrapperFactory;
|
|
43
38
|
}
|
|
44
39
|
};
|
|
45
40
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 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 ReactNoopUpdateQueue
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var warning = require("./warning");
|
|
15
|
+
|
|
16
|
+
function warnTDZ(publicInstance, callerName) {
|
|
17
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
18
|
+
'production' !== process.env.NODE_ENV ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') : undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* This is the abstract API for an update queue.
|
|
24
|
+
*/
|
|
25
|
+
var ReactNoopUpdateQueue = {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Checks whether or not this composite component is mounted.
|
|
29
|
+
* @param {ReactClass} publicInstance The instance we want to test.
|
|
30
|
+
* @return {boolean} True if mounted, false otherwise.
|
|
31
|
+
* @protected
|
|
32
|
+
* @final
|
|
33
|
+
*/
|
|
34
|
+
isMounted: function (publicInstance) {
|
|
35
|
+
return false;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Enqueue a callback that will be executed after all the pending updates
|
|
40
|
+
* have processed.
|
|
41
|
+
*
|
|
42
|
+
* @param {ReactClass} publicInstance The instance to use as `this` context.
|
|
43
|
+
* @param {?function} callback Called after state is updated.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
enqueueCallback: function (publicInstance, callback) {},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Forces an update. This should only be invoked when it is known with
|
|
50
|
+
* certainty that we are **not** in a DOM transaction.
|
|
51
|
+
*
|
|
52
|
+
* You may want to call this when you know that some deeper aspect of the
|
|
53
|
+
* component's state has changed but `setState` was not called.
|
|
54
|
+
*
|
|
55
|
+
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
|
56
|
+
* `componentWillUpdate` and `componentDidUpdate`.
|
|
57
|
+
*
|
|
58
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
enqueueForceUpdate: function (publicInstance) {
|
|
62
|
+
warnTDZ(publicInstance, 'forceUpdate');
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Replaces all of the state. Always use this or `setState` to mutate state.
|
|
67
|
+
* You should treat `this.state` as immutable.
|
|
68
|
+
*
|
|
69
|
+
* There is no guarantee that `this.state` will be immediately updated, so
|
|
70
|
+
* accessing `this.state` after calling this method may return the old value.
|
|
71
|
+
*
|
|
72
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
73
|
+
* @param {object} completeState Next state.
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
enqueueReplaceState: function (publicInstance, completeState) {
|
|
77
|
+
warnTDZ(publicInstance, 'replaceState');
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Sets a subset of the state. This only exists because _pendingState is
|
|
82
|
+
* internal. This provides a merging strategy that is not available to deep
|
|
83
|
+
* properties which is confusing. TODO: Expose pendingState or don't use it
|
|
84
|
+
* during the merge.
|
|
85
|
+
*
|
|
86
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
87
|
+
* @param {object} partialState Next partial state to be merged with state.
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
enqueueSetState: function (publicInstance, partialState) {
|
|
91
|
+
warnTDZ(publicInstance, 'setState');
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Sets a subset of the props.
|
|
96
|
+
*
|
|
97
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
98
|
+
* @param {object} partialProps Subset of the next props.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
enqueueSetProps: function (publicInstance, partialProps) {
|
|
102
|
+
warnTDZ(publicInstance, 'setProps');
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Replaces all of the props.
|
|
107
|
+
*
|
|
108
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
109
|
+
* @param {object} props New props.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
enqueueReplaceProps: function (publicInstance, props) {
|
|
113
|
+
warnTDZ(publicInstance, 'replaceProps');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
module.exports = ReactNoopUpdateQueue;
|