react 0.12.2 → 0.13.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/JSXTransformer.js +6 -4
- package/dist/react-with-addons.js +4022 -3267
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +3853 -3358
- package/dist/react.min.js +6 -6
- package/lib/BeforeInputEventPlugin.js +388 -111
- package/lib/CSSPropertyOperations.js +20 -0
- package/lib/ChangeEventPlugin.js +2 -2
- package/lib/Danger.js +1 -1
- package/lib/DefaultEventPluginOrder.js +0 -1
- package/lib/ExecutionEnvironment.js +2 -3
- package/lib/FallbackCompositionState.js +87 -0
- package/lib/HTMLDOMPropertyConfig.js +1 -0
- package/lib/Object.assign.js +3 -1
- package/lib/React.js +14 -49
- package/lib/ReactBrowserComponentMixin.js +2 -12
- package/lib/ReactBrowserEventEmitter.js +2 -4
- package/lib/ReactCSSTransitionGroup.js +3 -0
- package/lib/ReactCSSTransitionGroupChild.js +8 -0
- package/lib/ReactChildReconciler.js +121 -0
- package/lib/ReactClass.js +916 -0
- package/lib/ReactComponent.js +36 -286
- package/lib/ReactComponentBrowserEnvironment.js +9 -82
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactCompositeComponent.js +608 -1026
- package/lib/ReactContext.js +5 -1
- package/lib/ReactDOM.js +2 -7
- package/lib/ReactDOMButton.js +4 -5
- package/lib/ReactDOMComponent.js +97 -69
- package/lib/ReactDOMForm.js +4 -5
- package/lib/ReactDOMIDOperations.js +55 -73
- package/lib/ReactDOMImg.js +3 -5
- package/lib/ReactDOMInput.js +4 -5
- package/lib/ReactDOMOption.js +4 -5
- package/lib/ReactDOMSelect.js +55 -63
- package/lib/ReactDOMSelection.js +5 -1
- package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +54 -34
- package/lib/ReactDOMTextarea.js +4 -5
- package/lib/ReactDefaultInjection.js +13 -7
- package/lib/ReactDefaultPerf.js +6 -5
- package/lib/ReactDefaultPerfAnalysis.js +1 -1
- package/lib/ReactElement.js +17 -11
- package/lib/ReactElementValidator.js +74 -37
- package/lib/ReactEmptyComponent.js +17 -10
- package/lib/ReactInjection.js +6 -4
- package/lib/ReactInputSelection.js +2 -3
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactMount.js +193 -64
- package/lib/ReactMultiChild.js +32 -42
- package/lib/ReactNativeComponent.js +45 -8
- package/lib/ReactOwner.js +3 -47
- package/lib/ReactPerf.js +20 -0
- package/lib/ReactPropTransferer.js +0 -55
- package/lib/ReactPropTypes.js +1 -17
- package/lib/ReactRef.js +96 -0
- package/lib/ReactServerRendering.js +3 -2
- package/lib/ReactTestUtils.js +82 -25
- package/lib/ReactTransitionGroup.js +47 -6
- package/lib/ReactUpdates.js +43 -42
- package/lib/SyntheticMouseEvent.js +1 -3
- package/lib/ViewportMetrics.js +1 -4
- package/lib/accumulate.js +47 -0
- package/lib/cloneWithProps.js +2 -2
- package/lib/copyProperties.js +2 -0
- package/lib/createFullPageComponent.js +2 -2
- package/lib/findDOMNode.js +52 -0
- package/lib/flattenChildren.js +1 -14
- package/lib/getIteratorFn.js +42 -0
- package/lib/instantiateReactComponent.js +88 -65
- package/lib/isNode.js +3 -4
- package/lib/isTextInputElement.js +1 -2
- package/lib/shouldUpdateReactComponent.js +13 -5
- package/lib/traverseAllChildren.js +110 -54
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -243
- package/lib/deprecated.js +0 -47
package/lib/ReactContext.js
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
"use strict";
|
|
13
13
|
|
|
14
14
|
var assign = require("./Object.assign");
|
|
15
|
+
var emptyObject = require("./emptyObject");
|
|
16
|
+
var monitorCodeUse = require("./monitorCodeUse");
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Keeps track of the current context.
|
|
@@ -25,7 +27,7 @@ var ReactContext = {
|
|
|
25
27
|
* @internal
|
|
26
28
|
* @type {object}
|
|
27
29
|
*/
|
|
28
|
-
current:
|
|
30
|
+
current: emptyObject,
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Temporarily extends the current context while executing scopedCallback.
|
|
@@ -44,6 +46,8 @@ var ReactContext = {
|
|
|
44
46
|
* @return {ReactComponent|array<ReactComponent>}
|
|
45
47
|
*/
|
|
46
48
|
withContext: function(newContext, scopedCallback) {
|
|
49
|
+
monitorCodeUse('react_with_context', {newContext: newContext});
|
|
50
|
+
|
|
47
51
|
var result;
|
|
48
52
|
var previousContext = ReactContext.current;
|
|
49
53
|
ReactContext.current = assign({}, previousContext, newContext);
|
package/lib/ReactDOM.js
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
var ReactElement = require("./ReactElement");
|
|
16
16
|
var ReactElementValidator = require("./ReactElementValidator");
|
|
17
|
-
var ReactLegacyElement = require("./ReactLegacyElement");
|
|
18
17
|
|
|
19
18
|
var mapObject = require("./mapObject");
|
|
20
19
|
|
|
@@ -26,13 +25,9 @@ var mapObject = require("./mapObject");
|
|
|
26
25
|
*/
|
|
27
26
|
function createDOMFactory(tag) {
|
|
28
27
|
if ("production" !== process.env.NODE_ENV) {
|
|
29
|
-
return
|
|
30
|
-
ReactElementValidator.createFactory(tag)
|
|
31
|
-
);
|
|
28
|
+
return ReactElementValidator.createFactory(tag);
|
|
32
29
|
}
|
|
33
|
-
return
|
|
34
|
-
ReactElement.createFactory(tag)
|
|
35
|
-
);
|
|
30
|
+
return ReactElement.createFactory(tag);
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
/**
|
package/lib/ReactDOMButton.js
CHANGED
|
@@ -13,14 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
15
15
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
16
|
-
var
|
|
16
|
+
var ReactClass = require("./ReactClass");
|
|
17
17
|
var ReactElement = require("./ReactElement");
|
|
18
|
-
var ReactDOM = require("./ReactDOM");
|
|
19
18
|
|
|
20
19
|
var keyMirror = require("./keyMirror");
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
var button = ReactElement.createFactory(ReactDOM.button.type);
|
|
21
|
+
var button = ReactElement.createFactory('button');
|
|
24
22
|
|
|
25
23
|
var mouseListenerNames = keyMirror({
|
|
26
24
|
onClick: true,
|
|
@@ -39,8 +37,9 @@ var mouseListenerNames = keyMirror({
|
|
|
39
37
|
* Implements a <button> native component that does not receive mouse events
|
|
40
38
|
* when `disabled` is set.
|
|
41
39
|
*/
|
|
42
|
-
var ReactDOMButton =
|
|
40
|
+
var ReactDOMButton = ReactClass.createClass({
|
|
43
41
|
displayName: 'ReactDOMButton',
|
|
42
|
+
tagName: 'BUTTON',
|
|
44
43
|
|
|
45
44
|
mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
|
|
46
45
|
|
package/lib/ReactDOMComponent.js
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
var CSSPropertyOperations = require("./CSSPropertyOperations");
|
|
16
16
|
var DOMProperty = require("./DOMProperty");
|
|
17
17
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
18
|
-
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
19
18
|
var ReactComponent = require("./ReactComponent");
|
|
20
19
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
21
20
|
var ReactMount = require("./ReactMount");
|
|
@@ -40,6 +39,11 @@ var STYLE = keyOf({style: null});
|
|
|
40
39
|
|
|
41
40
|
var ELEMENT_NODE_TYPE = 1;
|
|
42
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Optionally injectable operations for mutating the DOM
|
|
44
|
+
*/
|
|
45
|
+
var BackendIDOperations = null;
|
|
46
|
+
|
|
43
47
|
/**
|
|
44
48
|
* @param {?object} props
|
|
45
49
|
*/
|
|
@@ -65,7 +69,8 @@ function assertValidProps(props) {
|
|
|
65
69
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
66
70
|
props.style == null || typeof props.style === 'object',
|
|
67
71
|
'The `style` prop expects a mapping from style properties to values, ' +
|
|
68
|
-
'not a string.'
|
|
72
|
+
'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' +
|
|
73
|
+
'using JSX.'
|
|
69
74
|
) : invariant(props.style == null || typeof props.style === 'object'));
|
|
70
75
|
}
|
|
71
76
|
|
|
@@ -148,7 +153,9 @@ function validateDangerousTag(tag) {
|
|
|
148
153
|
function ReactDOMComponent(tag) {
|
|
149
154
|
validateDangerousTag(tag);
|
|
150
155
|
this._tag = tag;
|
|
151
|
-
this.
|
|
156
|
+
this._renderedChildren = null;
|
|
157
|
+
this._previousStyleCopy = null;
|
|
158
|
+
this._rootNodeID = null;
|
|
152
159
|
}
|
|
153
160
|
|
|
154
161
|
ReactDOMComponent.displayName = 'ReactDOMComponent';
|
|
@@ -162,28 +169,24 @@ ReactDOMComponent.Mixin = {
|
|
|
162
169
|
* @internal
|
|
163
170
|
* @param {string} rootID The root DOM ID for this node.
|
|
164
171
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
165
|
-
* @param {number} mountDepth number of components in the owner hierarchy
|
|
166
172
|
* @return {string} The computed markup.
|
|
167
173
|
*/
|
|
168
|
-
mountComponent:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
),
|
|
174
|
+
mountComponent: function(rootID, transaction, context) {
|
|
175
|
+
ReactComponent.Mixin.mountComponent.call(
|
|
176
|
+
this,
|
|
177
|
+
rootID,
|
|
178
|
+
transaction,
|
|
179
|
+
context
|
|
180
|
+
);
|
|
181
|
+
this._rootNodeID = rootID;
|
|
182
|
+
assertValidProps(this._currentElement.props);
|
|
183
|
+
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
|
|
184
|
+
return (
|
|
185
|
+
this._createOpenTagMarkupAndPutListeners(transaction) +
|
|
186
|
+
this._createContentMarkup(transaction, context) +
|
|
187
|
+
closeTag
|
|
188
|
+
);
|
|
189
|
+
},
|
|
187
190
|
|
|
188
191
|
/**
|
|
189
192
|
* Creates markup for the open tag and all attributes.
|
|
@@ -198,7 +201,7 @@ ReactDOMComponent.Mixin = {
|
|
|
198
201
|
* @return {string} Markup of opening tag.
|
|
199
202
|
*/
|
|
200
203
|
_createOpenTagMarkupAndPutListeners: function(transaction) {
|
|
201
|
-
var props = this.props;
|
|
204
|
+
var props = this._currentElement.props;
|
|
202
205
|
var ret = '<' + this._tag;
|
|
203
206
|
|
|
204
207
|
for (var propKey in props) {
|
|
@@ -214,7 +217,7 @@ ReactDOMComponent.Mixin = {
|
|
|
214
217
|
} else {
|
|
215
218
|
if (propKey === STYLE) {
|
|
216
219
|
if (propValue) {
|
|
217
|
-
propValue =
|
|
220
|
+
propValue = this._previousStyleCopy = assign({}, props.style);
|
|
218
221
|
}
|
|
219
222
|
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
|
|
220
223
|
}
|
|
@@ -241,33 +244,47 @@ ReactDOMComponent.Mixin = {
|
|
|
241
244
|
*
|
|
242
245
|
* @private
|
|
243
246
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
247
|
+
* @param {object} context
|
|
244
248
|
* @return {string} Content markup.
|
|
245
249
|
*/
|
|
246
|
-
_createContentMarkup: function(transaction) {
|
|
250
|
+
_createContentMarkup: function(transaction, context) {
|
|
251
|
+
var prefix = '';
|
|
252
|
+
if (this._tag === 'listing' ||
|
|
253
|
+
this._tag === 'pre' ||
|
|
254
|
+
this._tag === 'textarea') {
|
|
255
|
+
// Add an initial newline because browsers ignore the first newline in
|
|
256
|
+
// a <listing>, <pre>, or <textarea> as an "authoring convenience" -- see
|
|
257
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody.
|
|
258
|
+
prefix = '\n';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
var props = this._currentElement.props;
|
|
262
|
+
|
|
247
263
|
// Intentional use of != to avoid catching zero/false.
|
|
248
|
-
var innerHTML =
|
|
264
|
+
var innerHTML = props.dangerouslySetInnerHTML;
|
|
249
265
|
if (innerHTML != null) {
|
|
250
266
|
if (innerHTML.__html != null) {
|
|
251
|
-
return innerHTML.__html;
|
|
267
|
+
return prefix + innerHTML.__html;
|
|
252
268
|
}
|
|
253
269
|
} else {
|
|
254
270
|
var contentToUse =
|
|
255
|
-
CONTENT_TYPES[typeof
|
|
256
|
-
var childrenToUse = contentToUse != null ? null :
|
|
271
|
+
CONTENT_TYPES[typeof props.children] ? props.children : null;
|
|
272
|
+
var childrenToUse = contentToUse != null ? null : props.children;
|
|
257
273
|
if (contentToUse != null) {
|
|
258
|
-
return escapeTextForBrowser(contentToUse);
|
|
274
|
+
return prefix + escapeTextForBrowser(contentToUse);
|
|
259
275
|
} else if (childrenToUse != null) {
|
|
260
276
|
var mountImages = this.mountChildren(
|
|
261
277
|
childrenToUse,
|
|
262
|
-
transaction
|
|
278
|
+
transaction,
|
|
279
|
+
context
|
|
263
280
|
);
|
|
264
|
-
return mountImages.join('');
|
|
281
|
+
return prefix + mountImages.join('');
|
|
265
282
|
}
|
|
266
283
|
}
|
|
267
|
-
return
|
|
284
|
+
return prefix;
|
|
268
285
|
},
|
|
269
286
|
|
|
270
|
-
receiveComponent: function(nextElement, transaction) {
|
|
287
|
+
receiveComponent: function(nextElement, transaction, context) {
|
|
271
288
|
if (nextElement === this._currentElement &&
|
|
272
289
|
nextElement._owner != null) {
|
|
273
290
|
// Since elements are immutable after the owner is rendered,
|
|
@@ -275,16 +292,14 @@ ReactDOMComponent.Mixin = {
|
|
|
275
292
|
// superfluous reconcile. It's possible for state to be mutable but such
|
|
276
293
|
// change should trigger an update of the owner which would recreate
|
|
277
294
|
// the element. We explicitly check for the existence of an owner since
|
|
278
|
-
// it's possible for
|
|
295
|
+
// it's possible for an element created outside a composite to be
|
|
279
296
|
// deeply mutated and reused.
|
|
280
297
|
return;
|
|
281
298
|
}
|
|
282
299
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
transaction
|
|
287
|
-
);
|
|
300
|
+
var prevElement = this._currentElement;
|
|
301
|
+
this._currentElement = nextElement;
|
|
302
|
+
this.updateComponent(transaction, prevElement, nextElement, context);
|
|
288
303
|
},
|
|
289
304
|
|
|
290
305
|
/**
|
|
@@ -293,23 +308,22 @@ ReactDOMComponent.Mixin = {
|
|
|
293
308
|
*
|
|
294
309
|
* @param {ReactReconcileTransaction} transaction
|
|
295
310
|
* @param {ReactElement} prevElement
|
|
311
|
+
* @param {ReactElement} nextElement
|
|
296
312
|
* @internal
|
|
297
313
|
* @overridable
|
|
298
314
|
*/
|
|
299
|
-
updateComponent:
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
),
|
|
315
|
+
updateComponent: function(transaction, prevElement, nextElement, context) {
|
|
316
|
+
assertValidProps(this._currentElement.props);
|
|
317
|
+
ReactComponent.Mixin.updateComponent.call(
|
|
318
|
+
this,
|
|
319
|
+
transaction,
|
|
320
|
+
prevElement,
|
|
321
|
+
nextElement,
|
|
322
|
+
context
|
|
323
|
+
);
|
|
324
|
+
this._updateDOMProperties(prevElement.props, transaction);
|
|
325
|
+
this._updateDOMChildren(prevElement.props, transaction, context);
|
|
326
|
+
},
|
|
313
327
|
|
|
314
328
|
/**
|
|
315
329
|
* Reconciles the properties by detecting differences in property values and
|
|
@@ -327,7 +341,7 @@ ReactDOMComponent.Mixin = {
|
|
|
327
341
|
* @param {ReactReconcileTransaction} transaction
|
|
328
342
|
*/
|
|
329
343
|
_updateDOMProperties: function(lastProps, transaction) {
|
|
330
|
-
var nextProps = this.props;
|
|
344
|
+
var nextProps = this._currentElement.props;
|
|
331
345
|
var propKey;
|
|
332
346
|
var styleName;
|
|
333
347
|
var styleUpdates;
|
|
@@ -337,7 +351,7 @@ ReactDOMComponent.Mixin = {
|
|
|
337
351
|
continue;
|
|
338
352
|
}
|
|
339
353
|
if (propKey === STYLE) {
|
|
340
|
-
var lastStyle =
|
|
354
|
+
var lastStyle = this._previousStyleCopy;
|
|
341
355
|
for (styleName in lastStyle) {
|
|
342
356
|
if (lastStyle.hasOwnProperty(styleName)) {
|
|
343
357
|
styleUpdates = styleUpdates || {};
|
|
@@ -349,7 +363,7 @@ ReactDOMComponent.Mixin = {
|
|
|
349
363
|
} else if (
|
|
350
364
|
DOMProperty.isStandardName[propKey] ||
|
|
351
365
|
DOMProperty.isCustomAttribute(propKey)) {
|
|
352
|
-
|
|
366
|
+
BackendIDOperations.deletePropertyByID(
|
|
353
367
|
this._rootNodeID,
|
|
354
368
|
propKey
|
|
355
369
|
);
|
|
@@ -357,13 +371,15 @@ ReactDOMComponent.Mixin = {
|
|
|
357
371
|
}
|
|
358
372
|
for (propKey in nextProps) {
|
|
359
373
|
var nextProp = nextProps[propKey];
|
|
360
|
-
var lastProp =
|
|
374
|
+
var lastProp = propKey === STYLE ?
|
|
375
|
+
this._previousStyleCopy :
|
|
376
|
+
lastProps[propKey];
|
|
361
377
|
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
|
|
362
378
|
continue;
|
|
363
379
|
}
|
|
364
380
|
if (propKey === STYLE) {
|
|
365
381
|
if (nextProp) {
|
|
366
|
-
nextProp =
|
|
382
|
+
nextProp = this._previousStyleCopy = assign({}, nextProp);
|
|
367
383
|
}
|
|
368
384
|
if (lastProp) {
|
|
369
385
|
// Unset styles on `lastProp` but not on `nextProp`.
|
|
@@ -391,7 +407,7 @@ ReactDOMComponent.Mixin = {
|
|
|
391
407
|
} else if (
|
|
392
408
|
DOMProperty.isStandardName[propKey] ||
|
|
393
409
|
DOMProperty.isCustomAttribute(propKey)) {
|
|
394
|
-
|
|
410
|
+
BackendIDOperations.updatePropertyByID(
|
|
395
411
|
this._rootNodeID,
|
|
396
412
|
propKey,
|
|
397
413
|
nextProp
|
|
@@ -399,7 +415,7 @@ ReactDOMComponent.Mixin = {
|
|
|
399
415
|
}
|
|
400
416
|
}
|
|
401
417
|
if (styleUpdates) {
|
|
402
|
-
|
|
418
|
+
BackendIDOperations.updateStylesByID(
|
|
403
419
|
this._rootNodeID,
|
|
404
420
|
styleUpdates
|
|
405
421
|
);
|
|
@@ -413,8 +429,8 @@ ReactDOMComponent.Mixin = {
|
|
|
413
429
|
* @param {object} lastProps
|
|
414
430
|
* @param {ReactReconcileTransaction} transaction
|
|
415
431
|
*/
|
|
416
|
-
_updateDOMChildren: function(lastProps, transaction) {
|
|
417
|
-
var nextProps = this.props;
|
|
432
|
+
_updateDOMChildren: function(lastProps, transaction, context) {
|
|
433
|
+
var nextProps = this._currentElement.props;
|
|
418
434
|
|
|
419
435
|
var lastContent =
|
|
420
436
|
CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
|
|
@@ -437,7 +453,7 @@ ReactDOMComponent.Mixin = {
|
|
|
437
453
|
var lastHasContentOrHtml = lastContent != null || lastHtml != null;
|
|
438
454
|
var nextHasContentOrHtml = nextContent != null || nextHtml != null;
|
|
439
455
|
if (lastChildren != null && nextChildren == null) {
|
|
440
|
-
this.updateChildren(null, transaction);
|
|
456
|
+
this.updateChildren(null, transaction, context);
|
|
441
457
|
} else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
|
|
442
458
|
this.updateTextContent('');
|
|
443
459
|
}
|
|
@@ -448,13 +464,13 @@ ReactDOMComponent.Mixin = {
|
|
|
448
464
|
}
|
|
449
465
|
} else if (nextHtml != null) {
|
|
450
466
|
if (lastHtml !== nextHtml) {
|
|
451
|
-
|
|
467
|
+
BackendIDOperations.updateInnerHTMLByID(
|
|
452
468
|
this._rootNodeID,
|
|
453
469
|
nextHtml
|
|
454
470
|
);
|
|
455
471
|
}
|
|
456
472
|
} else if (nextChildren != null) {
|
|
457
|
-
this.updateChildren(nextChildren, transaction);
|
|
473
|
+
this.updateChildren(nextChildren, transaction, context);
|
|
458
474
|
}
|
|
459
475
|
},
|
|
460
476
|
|
|
@@ -468,16 +484,28 @@ ReactDOMComponent.Mixin = {
|
|
|
468
484
|
this.unmountChildren();
|
|
469
485
|
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
|
|
470
486
|
ReactComponent.Mixin.unmountComponent.call(this);
|
|
487
|
+
ReactMount.purgeID(this._rootNodeID);
|
|
488
|
+
this._rootNodeID = null;
|
|
471
489
|
}
|
|
472
490
|
|
|
473
491
|
};
|
|
474
492
|
|
|
493
|
+
ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', {
|
|
494
|
+
mountComponent: 'mountComponent',
|
|
495
|
+
updateComponent: 'updateComponent'
|
|
496
|
+
});
|
|
497
|
+
|
|
475
498
|
assign(
|
|
476
499
|
ReactDOMComponent.prototype,
|
|
477
500
|
ReactComponent.Mixin,
|
|
478
501
|
ReactDOMComponent.Mixin,
|
|
479
|
-
ReactMultiChild.Mixin
|
|
480
|
-
ReactBrowserComponentMixin
|
|
502
|
+
ReactMultiChild.Mixin
|
|
481
503
|
);
|
|
482
504
|
|
|
505
|
+
ReactDOMComponent.injection = {
|
|
506
|
+
injectIDOperations: function(IDOperations) {
|
|
507
|
+
ReactDOMComponent.BackendIDOperations = BackendIDOperations = IDOperations;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
483
511
|
module.exports = ReactDOMComponent;
|
package/lib/ReactDOMForm.js
CHANGED
|
@@ -14,12 +14,10 @@
|
|
|
14
14
|
var EventConstants = require("./EventConstants");
|
|
15
15
|
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
|
|
16
16
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
17
|
-
var
|
|
17
|
+
var ReactClass = require("./ReactClass");
|
|
18
18
|
var ReactElement = require("./ReactElement");
|
|
19
|
-
var ReactDOM = require("./ReactDOM");
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
var form = ReactElement.createFactory(ReactDOM.form.type);
|
|
20
|
+
var form = ReactElement.createFactory('form');
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
|
|
@@ -27,8 +25,9 @@ var form = ReactElement.createFactory(ReactDOM.form.type);
|
|
|
27
25
|
* do to accomplish this, but the most reliable is to make <form> a
|
|
28
26
|
* composite component and use `componentDidMount` to attach the event handlers.
|
|
29
27
|
*/
|
|
30
|
-
var ReactDOMForm =
|
|
28
|
+
var ReactDOMForm = ReactClass.createClass({
|
|
31
29
|
displayName: 'ReactDOMForm',
|
|
30
|
+
tagName: 'FORM',
|
|
32
31
|
|
|
33
32
|
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
|
|
34
33
|
|
|
@@ -37,7 +37,7 @@ var INVALID_PROPERTY_ERRORS = {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Operations used to process updates to DOM nodes. This is made injectable via
|
|
40
|
-
* `
|
|
40
|
+
* `ReactDOMComponent.BackendIDOperations`.
|
|
41
41
|
*/
|
|
42
42
|
var ReactDOMIDOperations = {
|
|
43
43
|
|
|
@@ -50,27 +50,23 @@ var ReactDOMIDOperations = {
|
|
|
50
50
|
* @param {*} value New value of the property.
|
|
51
51
|
* @internal
|
|
52
52
|
*/
|
|
53
|
-
updatePropertyByID:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
DOMPropertyOperations.setValueForProperty(node, name, value);
|
|
69
|
-
} else {
|
|
70
|
-
DOMPropertyOperations.deleteValueForProperty(node, name);
|
|
71
|
-
}
|
|
53
|
+
updatePropertyByID: function(id, name, value) {
|
|
54
|
+
var node = ReactMount.getNode(id);
|
|
55
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
56
|
+
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
|
|
57
|
+
'updatePropertyByID(...): %s',
|
|
58
|
+
INVALID_PROPERTY_ERRORS[name]
|
|
59
|
+
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
|
60
|
+
|
|
61
|
+
// If we're updating to null or undefined, we should remove the property
|
|
62
|
+
// from the DOM node instead of inadvertantly setting to a string. This
|
|
63
|
+
// brings us in line with the same behavior we have on initial render.
|
|
64
|
+
if (value != null) {
|
|
65
|
+
DOMPropertyOperations.setValueForProperty(node, name, value);
|
|
66
|
+
} else {
|
|
67
|
+
DOMPropertyOperations.deleteValueForProperty(node, name);
|
|
72
68
|
}
|
|
73
|
-
|
|
69
|
+
},
|
|
74
70
|
|
|
75
71
|
/**
|
|
76
72
|
* Updates a DOM node to remove a property. This should only be used to remove
|
|
@@ -80,19 +76,15 @@ var ReactDOMIDOperations = {
|
|
|
80
76
|
* @param {string} name A property name to remove, see `DOMProperty`.
|
|
81
77
|
* @internal
|
|
82
78
|
*/
|
|
83
|
-
deletePropertyByID:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
|
93
|
-
DOMPropertyOperations.deleteValueForProperty(node, name, value);
|
|
94
|
-
}
|
|
95
|
-
),
|
|
79
|
+
deletePropertyByID: function(id, name, value) {
|
|
80
|
+
var node = ReactMount.getNode(id);
|
|
81
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
82
|
+
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
|
|
83
|
+
'updatePropertyByID(...): %s',
|
|
84
|
+
INVALID_PROPERTY_ERRORS[name]
|
|
85
|
+
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
|
86
|
+
DOMPropertyOperations.deleteValueForProperty(node, name, value);
|
|
87
|
+
},
|
|
96
88
|
|
|
97
89
|
/**
|
|
98
90
|
* Updates a DOM node with new style values. If a value is specified as '',
|
|
@@ -102,14 +94,10 @@ var ReactDOMIDOperations = {
|
|
|
102
94
|
* @param {object} styles Mapping from styles to values.
|
|
103
95
|
* @internal
|
|
104
96
|
*/
|
|
105
|
-
updateStylesByID:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var node = ReactMount.getNode(id);
|
|
110
|
-
CSSPropertyOperations.setValueForStyles(node, styles);
|
|
111
|
-
}
|
|
112
|
-
),
|
|
97
|
+
updateStylesByID: function(id, styles) {
|
|
98
|
+
var node = ReactMount.getNode(id);
|
|
99
|
+
CSSPropertyOperations.setValueForStyles(node, styles);
|
|
100
|
+
},
|
|
113
101
|
|
|
114
102
|
/**
|
|
115
103
|
* Updates a DOM node's innerHTML.
|
|
@@ -118,14 +106,10 @@ var ReactDOMIDOperations = {
|
|
|
118
106
|
* @param {string} html An HTML string.
|
|
119
107
|
* @internal
|
|
120
108
|
*/
|
|
121
|
-
updateInnerHTMLByID:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
var node = ReactMount.getNode(id);
|
|
126
|
-
setInnerHTML(node, html);
|
|
127
|
-
}
|
|
128
|
-
),
|
|
109
|
+
updateInnerHTMLByID: function(id, html) {
|
|
110
|
+
var node = ReactMount.getNode(id);
|
|
111
|
+
setInnerHTML(node, html);
|
|
112
|
+
},
|
|
129
113
|
|
|
130
114
|
/**
|
|
131
115
|
* Updates a DOM node's text content set by `props.content`.
|
|
@@ -134,14 +118,10 @@ var ReactDOMIDOperations = {
|
|
|
134
118
|
* @param {string} content Text content.
|
|
135
119
|
* @internal
|
|
136
120
|
*/
|
|
137
|
-
updateTextContentByID:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
var node = ReactMount.getNode(id);
|
|
142
|
-
DOMChildrenOperations.updateTextContent(node, content);
|
|
143
|
-
}
|
|
144
|
-
),
|
|
121
|
+
updateTextContentByID: function(id, content) {
|
|
122
|
+
var node = ReactMount.getNode(id);
|
|
123
|
+
DOMChildrenOperations.updateTextContent(node, content);
|
|
124
|
+
},
|
|
145
125
|
|
|
146
126
|
/**
|
|
147
127
|
* Replaces a DOM node that exists in the document with markup.
|
|
@@ -151,14 +131,10 @@ var ReactDOMIDOperations = {
|
|
|
151
131
|
* @internal
|
|
152
132
|
* @see {Danger.dangerouslyReplaceNodeWithMarkup}
|
|
153
133
|
*/
|
|
154
|
-
dangerouslyReplaceNodeWithMarkupByID:
|
|
155
|
-
'ReactDOMIDOperations',
|
|
156
|
-
'dangerouslyReplaceNodeWithMarkupByID',
|
|
157
|
-
function(id, markup) {
|
|
134
|
+
dangerouslyReplaceNodeWithMarkupByID: function(id, markup) {
|
|
158
135
|
var node = ReactMount.getNode(id);
|
|
159
136
|
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
|
|
160
|
-
|
|
161
|
-
),
|
|
137
|
+
},
|
|
162
138
|
|
|
163
139
|
/**
|
|
164
140
|
* Updates a component's children by processing a series of updates.
|
|
@@ -167,16 +143,22 @@ var ReactDOMIDOperations = {
|
|
|
167
143
|
* @param {array<string>} markup List of markup strings.
|
|
168
144
|
* @internal
|
|
169
145
|
*/
|
|
170
|
-
dangerouslyProcessChildrenUpdates:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
function(updates, markup) {
|
|
174
|
-
for (var i = 0; i < updates.length; i++) {
|
|
175
|
-
updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
|
|
176
|
-
}
|
|
177
|
-
DOMChildrenOperations.processUpdates(updates, markup);
|
|
146
|
+
dangerouslyProcessChildrenUpdates: function(updates, markup) {
|
|
147
|
+
for (var i = 0; i < updates.length; i++) {
|
|
148
|
+
updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
|
|
178
149
|
}
|
|
179
|
-
|
|
150
|
+
DOMChildrenOperations.processUpdates(updates, markup);
|
|
151
|
+
}
|
|
180
152
|
};
|
|
181
153
|
|
|
154
|
+
ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
|
|
155
|
+
updatePropertyByID: 'updatePropertyByID',
|
|
156
|
+
deletePropertyByID: 'deletePropertyByID',
|
|
157
|
+
updateStylesByID: 'updateStylesByID',
|
|
158
|
+
updateInnerHTMLByID: 'updateInnerHTMLByID',
|
|
159
|
+
updateTextContentByID: 'updateTextContentByID',
|
|
160
|
+
dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
|
|
161
|
+
dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
|
|
162
|
+
});
|
|
163
|
+
|
|
182
164
|
module.exports = ReactDOMIDOperations;
|