react 0.9.0 → 0.11.0
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 +3 -0
- package/dist/JSXTransformer.js +13448 -0
- package/dist/react-with-addons.js +20235 -0
- package/dist/react-with-addons.min.js +22 -0
- package/dist/react.js +18443 -0
- package/dist/react.min.js +21 -0
- package/lib/AutoFocusMixin.js +3 -1
- package/lib/BeforeInputEventPlugin.js +222 -0
- package/lib/CSSPropertyOperations.js +3 -3
- package/lib/{ReactMountReady.js → CallbackQueue.js} +32 -24
- package/lib/ChangeEventPlugin.js +1 -1
- package/lib/CompositionEventPlugin.js +5 -1
- package/lib/DOMChildrenOperations.js +33 -20
- package/lib/DOMProperty.js +51 -21
- package/lib/DOMPropertyOperations.js +28 -16
- package/lib/DefaultEventPluginOrder.js +1 -0
- package/lib/EventConstants.js +1 -0
- package/lib/EventListener.js +5 -2
- package/lib/EventPluginHub.js +2 -5
- package/lib/EventPluginRegistry.js +6 -4
- package/lib/EventPluginUtils.js +11 -1
- package/lib/ExecutionEnvironment.js +8 -2
- package/lib/{DefaultDOMPropertyConfig.js → HTMLDOMPropertyConfig.js} +41 -58
- package/lib/LinkedValueUtils.js +26 -28
- package/lib/LocalEventTrapMixin.js +52 -0
- package/lib/React.js +39 -3
- package/lib/ReactBrowserComponentMixin.js +46 -0
- package/lib/{ReactEventEmitter.js → ReactBrowserEventEmitter.js} +115 -94
- package/lib/ReactCSSTransitionGroup.js +12 -10
- package/lib/ReactCSSTransitionGroupChild.js +2 -5
- package/lib/ReactChildren.js +31 -10
- package/lib/ReactComponent.js +119 -223
- package/lib/ReactComponentBrowserEnvironment.js +3 -36
- package/lib/ReactComponentWithPureRenderMixin.js +54 -0
- package/lib/ReactCompositeComponent.js +249 -287
- package/lib/ReactDOM.js +25 -23
- package/lib/ReactDOMButton.js +2 -1
- package/lib/ReactDOMComponent.js +42 -23
- package/lib/ReactDOMForm.js +7 -12
- package/lib/ReactDOMIDOperations.js +2 -31
- package/lib/ReactDOMImg.js +7 -13
- package/lib/ReactDOMInput.js +2 -1
- package/lib/ReactDOMOption.js +11 -7
- package/lib/ReactDOMSelect.js +18 -16
- package/lib/ReactDOMSelection.js +35 -10
- package/lib/ReactDOMTextarea.js +9 -7
- package/lib/ReactDefaultBatchingStrategy.js +3 -3
- package/lib/ReactDefaultInjection.js +27 -14
- package/lib/ReactDefaultPerf.js +28 -11
- package/lib/ReactDefaultPerfAnalysis.js +4 -0
- package/lib/ReactDescriptor.js +251 -0
- package/lib/ReactDescriptorValidator.js +283 -0
- package/lib/ReactEmptyComponent.js +78 -0
- package/lib/ReactEventEmitterMixin.js +1 -3
- package/lib/ReactEventListener.js +189 -0
- package/lib/ReactInjection.js +8 -2
- package/lib/ReactInputSelection.js +2 -1
- package/lib/ReactLink.js +24 -0
- package/lib/ReactMount.js +61 -21
- package/lib/ReactMultiChild.js +18 -13
- package/lib/ReactOwner.js +6 -1
- package/lib/ReactPropTransferer.js +44 -29
- package/lib/ReactPropTypes.js +226 -242
- package/lib/ReactPutListenerQueue.js +2 -2
- package/lib/ReactReconcileTransaction.js +21 -20
- package/lib/ReactServerRendering.js +41 -11
- package/lib/ReactServerRenderingTransaction.js +115 -0
- package/lib/ReactTestUtils.js +39 -21
- package/lib/ReactTextComponent.js +21 -13
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +19 -0
- package/lib/ReactTransitionGroup.js +9 -6
- package/lib/ReactUpdates.js +139 -22
- package/lib/ReactWithAddons.js +8 -3
- package/lib/SVGDOMPropertyConfig.js +97 -0
- package/lib/SimpleEventPlugin.js +7 -1
- package/lib/SyntheticInputEvent.js +52 -0
- package/lib/SyntheticKeyboardEvent.js +33 -4
- package/lib/SyntheticMouseEvent.js +3 -0
- package/lib/SyntheticTouchEvent.js +4 -1
- package/lib/SyntheticUIEvent.js +24 -2
- package/lib/Transaction.js +0 -32
- package/lib/cloneWithProps.js +10 -8
- package/lib/createFullPageComponent.js +1 -1
- package/lib/dangerousStyleValue.js +11 -5
- package/lib/{ReactComponentEnvironment.js → emptyObject.js} +6 -5
- package/lib/escapeTextForBrowser.js +2 -3
- package/lib/flattenChildren.js +9 -7
- package/lib/focusNode.js +33 -0
- package/lib/getEventKey.js +35 -5
- package/lib/getEventModifierState.js +52 -0
- package/lib/getMarkupWrap.js +2 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/hyphenate.js +3 -0
- package/lib/hyphenateStyleName.js +46 -0
- package/lib/instantiateReactComponent.js +62 -0
- package/lib/invariant.js +17 -19
- package/lib/isNode.js +1 -1
- package/lib/{objMap.js → mapObject.js} +8 -3
- package/lib/mergeHelpers.js +11 -0
- package/lib/mergeInto.js +3 -2
- package/lib/monitorCodeUse.js +37 -0
- package/lib/onlyChild.js +3 -3
- package/lib/performance.js +33 -0
- package/lib/performanceNow.js +5 -14
- package/lib/setInnerHTML.js +77 -0
- package/lib/shouldUpdateReactComponent.js +14 -28
- package/lib/toArray.js +1 -1
- package/lib/traverseAllChildren.js +9 -5
- package/lib/update.js +171 -0
- package/package.json +4 -3
- package/lib/ReactEventTopLevelCallback.js +0 -149
- package/lib/createObjectFrom.js +0 -61
- package/lib/objMapKeyVal.js +0 -47
package/lib/ReactDOM.js
CHANGED
|
@@ -19,10 +19,12 @@
|
|
|
19
19
|
|
|
20
20
|
"use strict";
|
|
21
21
|
|
|
22
|
+
var ReactDescriptor = require("./ReactDescriptor");
|
|
23
|
+
var ReactDescriptorValidator = require("./ReactDescriptorValidator");
|
|
22
24
|
var ReactDOMComponent = require("./ReactDOMComponent");
|
|
23
25
|
|
|
24
26
|
var mergeInto = require("./mergeInto");
|
|
25
|
-
var
|
|
27
|
+
var mapObject = require("./mapObject");
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* Creates a new React class that is idempotent and capable of containing other
|
|
@@ -35,30 +37,26 @@ var objMapKeyVal = require("./objMapKeyVal");
|
|
|
35
37
|
* The `style` property functions differently from the DOM API. It accepts an
|
|
36
38
|
* object mapping of style properties to values.
|
|
37
39
|
*
|
|
38
|
-
* @param {string} tag Tag name (e.g. `div`).
|
|
39
40
|
* @param {boolean} omitClose True if the close tag should be omitted.
|
|
41
|
+
* @param {string} tag Tag name (e.g. `div`).
|
|
40
42
|
* @private
|
|
41
43
|
*/
|
|
42
|
-
function createDOMComponentClass(
|
|
43
|
-
var Constructor = function() {
|
|
44
|
+
function createDOMComponentClass(omitClose, tag) {
|
|
45
|
+
var Constructor = function(descriptor) {
|
|
46
|
+
this.construct(descriptor);
|
|
47
|
+
};
|
|
44
48
|
Constructor.prototype = new ReactDOMComponent(tag, omitClose);
|
|
45
49
|
Constructor.prototype.constructor = Constructor;
|
|
46
50
|
Constructor.displayName = tag;
|
|
47
51
|
|
|
48
|
-
var ConvenienceConstructor =
|
|
49
|
-
var instance = new Constructor();
|
|
50
|
-
instance.construct.apply(instance, arguments);
|
|
51
|
-
return instance;
|
|
52
|
-
};
|
|
52
|
+
var ConvenienceConstructor = ReactDescriptor.createFactory(Constructor);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
55
|
+
return ReactDescriptorValidator.createFactory(
|
|
56
|
+
ConvenienceConstructor
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
59
|
|
|
60
|
-
Constructor.ConvenienceConstructor = ConvenienceConstructor;
|
|
61
|
-
ConvenienceConstructor.componentConstructor = Constructor;
|
|
62
60
|
return ConvenienceConstructor;
|
|
63
61
|
}
|
|
64
62
|
|
|
@@ -68,16 +66,16 @@ function createDOMComponentClass(tag, omitClose) {
|
|
|
68
66
|
*
|
|
69
67
|
* @public
|
|
70
68
|
*/
|
|
71
|
-
var ReactDOM =
|
|
69
|
+
var ReactDOM = mapObject({
|
|
72
70
|
a: false,
|
|
73
71
|
abbr: false,
|
|
74
72
|
address: false,
|
|
75
|
-
area:
|
|
73
|
+
area: true,
|
|
76
74
|
article: false,
|
|
77
75
|
aside: false,
|
|
78
76
|
audio: false,
|
|
79
77
|
b: false,
|
|
80
|
-
base:
|
|
78
|
+
base: true,
|
|
81
79
|
bdi: false,
|
|
82
80
|
bdo: false,
|
|
83
81
|
big: false,
|
|
@@ -127,7 +125,7 @@ var ReactDOM = objMapKeyVal({
|
|
|
127
125
|
label: false,
|
|
128
126
|
legend: false,
|
|
129
127
|
li: false,
|
|
130
|
-
link:
|
|
128
|
+
link: true,
|
|
131
129
|
main: false,
|
|
132
130
|
map: false,
|
|
133
131
|
mark: false,
|
|
@@ -156,7 +154,7 @@ var ReactDOM = objMapKeyVal({
|
|
|
156
154
|
section: false,
|
|
157
155
|
select: false,
|
|
158
156
|
small: false,
|
|
159
|
-
source:
|
|
157
|
+
source: true,
|
|
160
158
|
span: false,
|
|
161
159
|
strong: false,
|
|
162
160
|
style: false,
|
|
@@ -178,22 +176,26 @@ var ReactDOM = objMapKeyVal({
|
|
|
178
176
|
ul: false,
|
|
179
177
|
'var': false,
|
|
180
178
|
video: false,
|
|
181
|
-
wbr:
|
|
179
|
+
wbr: true,
|
|
182
180
|
|
|
183
181
|
// SVG
|
|
184
182
|
circle: false,
|
|
185
183
|
defs: false,
|
|
184
|
+
ellipse: false,
|
|
186
185
|
g: false,
|
|
187
186
|
line: false,
|
|
188
187
|
linearGradient: false,
|
|
188
|
+
mask: false,
|
|
189
189
|
path: false,
|
|
190
|
+
pattern: false,
|
|
190
191
|
polygon: false,
|
|
191
192
|
polyline: false,
|
|
192
193
|
radialGradient: false,
|
|
193
194
|
rect: false,
|
|
194
195
|
stop: false,
|
|
195
196
|
svg: false,
|
|
196
|
-
text: false
|
|
197
|
+
text: false,
|
|
198
|
+
tspan: false
|
|
197
199
|
}, createDOMComponentClass);
|
|
198
200
|
|
|
199
201
|
var injection = {
|
package/lib/ReactDOMButton.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"use strict";
|
|
20
20
|
|
|
21
21
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
22
|
+
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
22
23
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
23
24
|
var ReactDOM = require("./ReactDOM");
|
|
24
25
|
|
|
@@ -47,7 +48,7 @@ var mouseListenerNames = keyMirror({
|
|
|
47
48
|
var ReactDOMButton = ReactCompositeComponent.createClass({
|
|
48
49
|
displayName: 'ReactDOMButton',
|
|
49
50
|
|
|
50
|
-
mixins: [AutoFocusMixin],
|
|
51
|
+
mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
|
|
51
52
|
|
|
52
53
|
render: function() {
|
|
53
54
|
var props = {};
|
package/lib/ReactDOMComponent.js
CHANGED
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
var CSSPropertyOperations = require("./CSSPropertyOperations");
|
|
23
23
|
var DOMProperty = require("./DOMProperty");
|
|
24
24
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
25
|
+
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
25
26
|
var ReactComponent = require("./ReactComponent");
|
|
26
|
-
var
|
|
27
|
+
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
27
28
|
var ReactMount = require("./ReactMount");
|
|
28
29
|
var ReactMultiChild = require("./ReactMultiChild");
|
|
29
30
|
var ReactPerf = require("./ReactPerf");
|
|
@@ -34,9 +35,9 @@ var keyOf = require("./keyOf");
|
|
|
34
35
|
var merge = require("./merge");
|
|
35
36
|
var mixInto = require("./mixInto");
|
|
36
37
|
|
|
37
|
-
var deleteListener =
|
|
38
|
-
var listenTo =
|
|
39
|
-
var registrationNameModules =
|
|
38
|
+
var deleteListener = ReactBrowserEventEmitter.deleteListener;
|
|
39
|
+
var listenTo = ReactBrowserEventEmitter.listenTo;
|
|
40
|
+
var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules;
|
|
40
41
|
|
|
41
42
|
// For quickly matching children type, to test if can be treated as content.
|
|
42
43
|
var CONTENT_TYPES = {'string': true, 'number': true};
|
|
@@ -99,7 +100,7 @@ ReactDOMComponent.Mixin = {
|
|
|
99
100
|
*
|
|
100
101
|
* @internal
|
|
101
102
|
* @param {string} rootID The root DOM ID for this node.
|
|
102
|
-
* @param {ReactReconcileTransaction} transaction
|
|
103
|
+
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
103
104
|
* @param {number} mountDepth number of components in the owner hierarchy
|
|
104
105
|
* @return {string} The computed markup.
|
|
105
106
|
*/
|
|
@@ -131,7 +132,7 @@ ReactDOMComponent.Mixin = {
|
|
|
131
132
|
* @see http://jsperf.com/obj-vs-arr-iteration
|
|
132
133
|
*
|
|
133
134
|
* @private
|
|
134
|
-
* @param {ReactReconcileTransaction} transaction
|
|
135
|
+
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
135
136
|
* @return {string} Markup of opening tag.
|
|
136
137
|
*/
|
|
137
138
|
_createOpenTagMarkupAndPutListeners: function(transaction) {
|
|
@@ -146,7 +147,7 @@ ReactDOMComponent.Mixin = {
|
|
|
146
147
|
if (propValue == null) {
|
|
147
148
|
continue;
|
|
148
149
|
}
|
|
149
|
-
if (registrationNameModules
|
|
150
|
+
if (registrationNameModules.hasOwnProperty(propKey)) {
|
|
150
151
|
putListener(this._rootNodeID, propKey, propValue, transaction);
|
|
151
152
|
} else {
|
|
152
153
|
if (propKey === STYLE) {
|
|
@@ -163,15 +164,21 @@ ReactDOMComponent.Mixin = {
|
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
// For static pages, no need to put React ID and checksum. Saves lots of
|
|
168
|
+
// bytes.
|
|
169
|
+
if (transaction.renderToStaticMarkup) {
|
|
170
|
+
return ret + '>';
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
|
|
174
|
+
return ret + ' ' + markupForID + '>';
|
|
168
175
|
},
|
|
169
176
|
|
|
170
177
|
/**
|
|
171
178
|
* Creates markup for the content between the tags.
|
|
172
179
|
*
|
|
173
180
|
* @private
|
|
174
|
-
* @param {ReactReconcileTransaction} transaction
|
|
181
|
+
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
175
182
|
* @return {string} Content markup.
|
|
176
183
|
*/
|
|
177
184
|
_createContentMarkup: function(transaction) {
|
|
@@ -198,11 +205,22 @@ ReactDOMComponent.Mixin = {
|
|
|
198
205
|
return '';
|
|
199
206
|
},
|
|
200
207
|
|
|
201
|
-
receiveComponent: function(
|
|
202
|
-
|
|
208
|
+
receiveComponent: function(nextDescriptor, transaction) {
|
|
209
|
+
if (nextDescriptor === this._descriptor &&
|
|
210
|
+
nextDescriptor._owner != null) {
|
|
211
|
+
// Since descriptors are immutable after the owner is rendered,
|
|
212
|
+
// we can do a cheap identity compare here to determine if this is a
|
|
213
|
+
// superfluous reconcile. It's possible for state to be mutable but such
|
|
214
|
+
// change should trigger an update of the owner which would recreate
|
|
215
|
+
// the descriptor. We explicitly check for the existence of an owner since
|
|
216
|
+
// it's possible for a descriptor created outside a composite to be
|
|
217
|
+
// deeply mutated and reused.
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
203
221
|
ReactComponent.Mixin.receiveComponent.call(
|
|
204
222
|
this,
|
|
205
|
-
|
|
223
|
+
nextDescriptor,
|
|
206
224
|
transaction
|
|
207
225
|
);
|
|
208
226
|
},
|
|
@@ -212,22 +230,22 @@ ReactDOMComponent.Mixin = {
|
|
|
212
230
|
* attached to the DOM. Reconciles the root DOM node, then recurses.
|
|
213
231
|
*
|
|
214
232
|
* @param {ReactReconcileTransaction} transaction
|
|
215
|
-
* @param {
|
|
233
|
+
* @param {ReactDescriptor} prevDescriptor
|
|
216
234
|
* @internal
|
|
217
235
|
* @overridable
|
|
218
236
|
*/
|
|
219
237
|
updateComponent: ReactPerf.measure(
|
|
220
238
|
'ReactDOMComponent',
|
|
221
239
|
'updateComponent',
|
|
222
|
-
function(transaction,
|
|
240
|
+
function(transaction, prevDescriptor) {
|
|
241
|
+
assertValidProps(this._descriptor.props);
|
|
223
242
|
ReactComponent.Mixin.updateComponent.call(
|
|
224
243
|
this,
|
|
225
244
|
transaction,
|
|
226
|
-
|
|
227
|
-
prevOwner
|
|
245
|
+
prevDescriptor
|
|
228
246
|
);
|
|
229
|
-
this._updateDOMProperties(
|
|
230
|
-
this._updateDOMChildren(
|
|
247
|
+
this._updateDOMProperties(prevDescriptor.props, transaction);
|
|
248
|
+
this._updateDOMChildren(prevDescriptor.props, transaction);
|
|
231
249
|
}
|
|
232
250
|
),
|
|
233
251
|
|
|
@@ -264,7 +282,7 @@ ReactDOMComponent.Mixin = {
|
|
|
264
282
|
styleUpdates[styleName] = '';
|
|
265
283
|
}
|
|
266
284
|
}
|
|
267
|
-
} else if (registrationNameModules
|
|
285
|
+
} else if (registrationNameModules.hasOwnProperty(propKey)) {
|
|
268
286
|
deleteListener(this._rootNodeID, propKey);
|
|
269
287
|
} else if (
|
|
270
288
|
DOMProperty.isStandardName[propKey] ||
|
|
@@ -289,7 +307,7 @@ ReactDOMComponent.Mixin = {
|
|
|
289
307
|
// Unset styles on `lastProp` but not on `nextProp`.
|
|
290
308
|
for (styleName in lastProp) {
|
|
291
309
|
if (lastProp.hasOwnProperty(styleName) &&
|
|
292
|
-
!nextProp.hasOwnProperty(styleName)) {
|
|
310
|
+
(!nextProp || !nextProp.hasOwnProperty(styleName))) {
|
|
293
311
|
styleUpdates = styleUpdates || {};
|
|
294
312
|
styleUpdates[styleName] = '';
|
|
295
313
|
}
|
|
@@ -306,7 +324,7 @@ ReactDOMComponent.Mixin = {
|
|
|
306
324
|
// Relies on `updateStylesByID` not mutating `styleUpdates`.
|
|
307
325
|
styleUpdates = nextProp;
|
|
308
326
|
}
|
|
309
|
-
} else if (registrationNameModules
|
|
327
|
+
} else if (registrationNameModules.hasOwnProperty(propKey)) {
|
|
310
328
|
putListener(this._rootNodeID, propKey, nextProp, transaction);
|
|
311
329
|
} else if (
|
|
312
330
|
DOMProperty.isStandardName[propKey] ||
|
|
@@ -386,7 +404,7 @@ ReactDOMComponent.Mixin = {
|
|
|
386
404
|
*/
|
|
387
405
|
unmountComponent: function() {
|
|
388
406
|
this.unmountChildren();
|
|
389
|
-
|
|
407
|
+
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
|
|
390
408
|
ReactComponent.Mixin.unmountComponent.call(this);
|
|
391
409
|
}
|
|
392
410
|
|
|
@@ -395,5 +413,6 @@ ReactDOMComponent.Mixin = {
|
|
|
395
413
|
mixInto(ReactDOMComponent, ReactComponent.Mixin);
|
|
396
414
|
mixInto(ReactDOMComponent, ReactDOMComponent.Mixin);
|
|
397
415
|
mixInto(ReactDOMComponent, ReactMultiChild.Mixin);
|
|
416
|
+
mixInto(ReactDOMComponent, ReactBrowserComponentMixin);
|
|
398
417
|
|
|
399
418
|
module.exports = ReactDOMComponent;
|
package/lib/ReactDOMForm.js
CHANGED
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
|
|
19
19
|
"use strict";
|
|
20
20
|
|
|
21
|
+
var EventConstants = require("./EventConstants");
|
|
22
|
+
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
|
|
23
|
+
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
21
24
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
22
25
|
var ReactDOM = require("./ReactDOM");
|
|
23
|
-
var ReactEventEmitter = require("./ReactEventEmitter");
|
|
24
|
-
var EventConstants = require("./EventConstants");
|
|
25
26
|
|
|
26
27
|
// Store a reference to the <form> `ReactDOMComponent`.
|
|
27
28
|
var form = ReactDOM.form;
|
|
@@ -35,6 +36,8 @@ var form = ReactDOM.form;
|
|
|
35
36
|
var ReactDOMForm = ReactCompositeComponent.createClass({
|
|
36
37
|
displayName: 'ReactDOMForm',
|
|
37
38
|
|
|
39
|
+
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
|
|
40
|
+
|
|
38
41
|
render: function() {
|
|
39
42
|
// TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
|
|
40
43
|
// `jshint` fails to parse JSX so in order for linting to work in the open
|
|
@@ -43,16 +46,8 @@ var ReactDOMForm = ReactCompositeComponent.createClass({
|
|
|
43
46
|
},
|
|
44
47
|
|
|
45
48
|
componentDidMount: function() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
'reset',
|
|
49
|
-
this.getDOMNode()
|
|
50
|
-
);
|
|
51
|
-
ReactEventEmitter.trapBubbledEvent(
|
|
52
|
-
EventConstants.topLevelTypes.topSubmit,
|
|
53
|
-
'submit',
|
|
54
|
-
this.getDOMNode()
|
|
55
|
-
);
|
|
49
|
+
this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');
|
|
50
|
+
this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');
|
|
56
51
|
}
|
|
57
52
|
});
|
|
58
53
|
|
|
@@ -28,6 +28,7 @@ var ReactMount = require("./ReactMount");
|
|
|
28
28
|
var ReactPerf = require("./ReactPerf");
|
|
29
29
|
|
|
30
30
|
var invariant = require("./invariant");
|
|
31
|
+
var setInnerHTML = require("./setInnerHTML");
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Errors for properties that should not be updated with `updatePropertyById()`.
|
|
@@ -41,8 +42,6 @@ var INVALID_PROPERTY_ERRORS = {
|
|
|
41
42
|
style: '`style` must be set using `updateStylesByID()`.'
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
var useWhitespaceWorkaround;
|
|
45
|
-
|
|
46
45
|
/**
|
|
47
46
|
* Operations used to process updates to DOM nodes. This is made injectable via
|
|
48
47
|
* `ReactComponent.BackendIDOperations`.
|
|
@@ -131,35 +130,7 @@ var ReactDOMIDOperations = {
|
|
|
131
130
|
'updateInnerHTMLByID',
|
|
132
131
|
function(id, html) {
|
|
133
132
|
var node = ReactMount.getNode(id);
|
|
134
|
-
|
|
135
|
-
// IE8: When updating a just created node with innerHTML only leading
|
|
136
|
-
// whitespace is removed. When updating an existing node with innerHTML
|
|
137
|
-
// whitespace in root TextNodes is also collapsed.
|
|
138
|
-
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
|
|
139
|
-
|
|
140
|
-
if (useWhitespaceWorkaround === undefined) {
|
|
141
|
-
// Feature detection; only IE8 is known to behave improperly like this.
|
|
142
|
-
var temp = document.createElement('div');
|
|
143
|
-
temp.innerHTML = ' ';
|
|
144
|
-
useWhitespaceWorkaround = temp.innerHTML === '';
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (useWhitespaceWorkaround) {
|
|
148
|
-
// Magic theory: IE8 supposedly differentiates between added and updated
|
|
149
|
-
// nodes when processing innerHTML, innerHTML on updated nodes suffers
|
|
150
|
-
// from worse whitespace behavior. Re-adding a node like this triggers
|
|
151
|
-
// the initial and more favorable whitespace behavior.
|
|
152
|
-
node.parentNode.replaceChild(node, node);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (useWhitespaceWorkaround && html.match(/^[ \r\n\t\f]/)) {
|
|
156
|
-
// Recover leading whitespace by temporarily prepending any character.
|
|
157
|
-
// \uFEFF has the potential advantage of being zero-width/invisible.
|
|
158
|
-
node.innerHTML = '\uFEFF' + html;
|
|
159
|
-
node.firstChild.deleteData(0, 1);
|
|
160
|
-
} else {
|
|
161
|
-
node.innerHTML = html;
|
|
162
|
-
}
|
|
133
|
+
setInnerHTML(node, html);
|
|
163
134
|
}
|
|
164
135
|
),
|
|
165
136
|
|
package/lib/ReactDOMImg.js
CHANGED
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
|
|
19
19
|
"use strict";
|
|
20
20
|
|
|
21
|
+
var EventConstants = require("./EventConstants");
|
|
22
|
+
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
|
|
23
|
+
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
21
24
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
22
25
|
var ReactDOM = require("./ReactDOM");
|
|
23
|
-
var ReactEventEmitter = require("./ReactEventEmitter");
|
|
24
|
-
var EventConstants = require("./EventConstants");
|
|
25
26
|
|
|
26
27
|
// Store a reference to the <img> `ReactDOMComponent`.
|
|
27
28
|
var img = ReactDOM.img;
|
|
@@ -36,22 +37,15 @@ var ReactDOMImg = ReactCompositeComponent.createClass({
|
|
|
36
37
|
displayName: 'ReactDOMImg',
|
|
37
38
|
tagName: 'IMG',
|
|
38
39
|
|
|
40
|
+
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
|
|
41
|
+
|
|
39
42
|
render: function() {
|
|
40
43
|
return img(this.props);
|
|
41
44
|
},
|
|
42
45
|
|
|
43
46
|
componentDidMount: function() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
EventConstants.topLevelTypes.topLoad,
|
|
47
|
-
'load',
|
|
48
|
-
node
|
|
49
|
-
);
|
|
50
|
-
ReactEventEmitter.trapBubbledEvent(
|
|
51
|
-
EventConstants.topLevelTypes.topError,
|
|
52
|
-
'error',
|
|
53
|
-
node
|
|
54
|
-
);
|
|
47
|
+
this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
|
|
48
|
+
this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error');
|
|
55
49
|
}
|
|
56
50
|
});
|
|
57
51
|
|
package/lib/ReactDOMInput.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
22
22
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
23
23
|
var LinkedValueUtils = require("./LinkedValueUtils");
|
|
24
|
+
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
24
25
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
25
26
|
var ReactDOM = require("./ReactDOM");
|
|
26
27
|
var ReactMount = require("./ReactMount");
|
|
@@ -52,7 +53,7 @@ var instancesByReactID = {};
|
|
|
52
53
|
var ReactDOMInput = ReactCompositeComponent.createClass({
|
|
53
54
|
displayName: 'ReactDOMInput',
|
|
54
55
|
|
|
55
|
-
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin],
|
|
56
|
+
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
|
|
56
57
|
|
|
57
58
|
getInitialState: function() {
|
|
58
59
|
var defaultValue = this.props.defaultValue;
|