react 0.11.2 → 0.12.2
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 +2714 -7859
- package/dist/react-with-addons.js +3139 -3593
- package/dist/react-with-addons.min.js +11 -17
- package/dist/react.js +2940 -3308
- package/dist/react.min.js +11 -16
- package/lib/AutoFocusMixin.js +5 -12
- package/lib/BeforeInputEventPlugin.js +12 -14
- package/lib/CSSCore.js +6 -13
- package/lib/CSSProperty.js +10 -14
- package/lib/CSSPropertyOperations.js +46 -12
- package/lib/CallbackQueue.js +7 -14
- package/lib/ChangeEventPlugin.js +5 -12
- package/lib/ClientReactRootIndex.js +5 -12
- package/lib/CompositionEventPlugin.js +5 -12
- package/lib/DOMChildrenOperations.js +8 -15
- package/lib/DOMProperty.js +16 -19
- package/lib/DOMPropertyOperations.js +14 -14
- package/lib/Danger.js +12 -17
- package/lib/DefaultEventPluginOrder.js +5 -12
- package/lib/EnterLeaveEventPlugin.js +5 -12
- package/lib/EventConstants.js +5 -12
- package/lib/EventListener.js +14 -0
- package/lib/EventPluginHub.js +8 -26
- package/lib/EventPluginRegistry.js +5 -12
- package/lib/EventPluginUtils.js +5 -12
- package/lib/EventPropagators.js +12 -17
- package/lib/ExecutionEnvironment.js +5 -12
- package/lib/HTMLDOMPropertyConfig.js +16 -15
- package/lib/LinkedStateMixin.js +5 -12
- package/lib/LinkedValueUtils.js +5 -12
- package/lib/LocalEventTrapMixin.js +8 -14
- package/lib/MobileSafariClickEventPlugin.js +5 -12
- package/lib/Object.assign.js +45 -0
- package/lib/PooledClass.js +5 -12
- package/lib/React.js +87 -54
- package/lib/ReactBrowserComponentMixin.js +5 -12
- package/lib/ReactBrowserEventEmitter.js +7 -14
- package/lib/ReactCSSTransitionGroup.js +15 -17
- package/lib/ReactCSSTransitionGroupChild.js +9 -13
- package/lib/ReactChildren.js +5 -12
- package/lib/ReactComponent.js +61 -68
- package/lib/ReactComponentBrowserEnvironment.js +5 -12
- package/lib/ReactComponentWithPureRenderMixin.js +5 -12
- package/lib/ReactCompositeComponent.js +191 -180
- package/lib/ReactContext.js +8 -15
- package/lib/ReactCurrentOwner.js +5 -12
- package/lib/ReactDOM.js +145 -177
- package/lib/ReactDOMButton.js +8 -14
- package/lib/ReactDOMComponent.js +103 -38
- package/lib/ReactDOMForm.js +9 -15
- package/lib/ReactDOMIDOperations.js +5 -12
- package/lib/ReactDOMImg.js +8 -14
- package/lib/ReactDOMInput.js +30 -38
- package/lib/ReactDOMOption.js +8 -14
- package/lib/ReactDOMSelect.js +25 -24
- package/lib/ReactDOMSelection.js +11 -18
- package/lib/ReactDOMTextarea.js +19 -24
- package/lib/ReactDefaultBatchingStrategy.js +14 -18
- package/lib/ReactDefaultInjection.js +23 -26
- package/lib/ReactDefaultPerf.js +14 -17
- package/lib/ReactDefaultPerfAnalysis.js +18 -17
- package/lib/ReactElement.js +242 -0
- package/lib/{ReactDescriptorValidator.js → ReactElementValidator.js} +51 -56
- package/lib/ReactEmptyComponent.js +8 -13
- package/lib/ReactErrorUtils.js +5 -12
- package/lib/ReactEventEmitterMixin.js +5 -12
- package/lib/ReactEventListener.js +7 -14
- package/lib/ReactInjection.js +7 -14
- package/lib/ReactInputSelection.js +5 -12
- package/lib/ReactInstanceHandles.js +5 -12
- package/lib/ReactLegacyElement.js +243 -0
- package/lib/ReactLink.js +5 -12
- package/lib/ReactMarkupChecksum.js +5 -12
- package/lib/ReactMount.js +45 -32
- package/lib/ReactMultiChild.js +14 -18
- package/lib/ReactMultiChildUpdateTypes.js +5 -12
- package/lib/ReactNativeComponent.js +69 -0
- package/lib/ReactOwner.js +5 -12
- package/lib/ReactPerf.js +8 -13
- package/lib/ReactPropTransferer.js +34 -33
- package/lib/ReactPropTypeLocationNames.js +5 -12
- package/lib/ReactPropTypeLocations.js +5 -12
- package/lib/ReactPropTypes.js +38 -29
- package/lib/ReactPutListenerQueue.js +7 -14
- package/lib/ReactReconcileTransaction.js +7 -15
- package/lib/ReactRootIndex.js +5 -12
- package/lib/ReactServerRendering.js +21 -34
- package/lib/ReactServerRenderingTransaction.js +11 -15
- package/lib/ReactStateSetters.js +5 -12
- package/lib/ReactTestUtils.js +31 -33
- package/lib/ReactTextComponent.js +18 -21
- package/lib/ReactTransitionChildMapping.js +6 -13
- package/lib/ReactTransitionEvents.js +5 -12
- package/lib/ReactTransitionGroup.js +14 -17
- package/lib/ReactUpdates.js +43 -22
- package/lib/ReactWithAddons.js +7 -13
- package/lib/SVGDOMPropertyConfig.js +5 -12
- package/lib/SelectEventPlugin.js +13 -20
- package/lib/ServerReactRootIndex.js +5 -12
- package/lib/SimpleEventPlugin.js +20 -15
- package/lib/SyntheticClipboardEvent.js +5 -12
- package/lib/SyntheticCompositionEvent.js +5 -12
- package/lib/SyntheticDragEvent.js +5 -12
- package/lib/SyntheticEvent.js +9 -17
- package/lib/SyntheticFocusEvent.js +5 -12
- package/lib/SyntheticInputEvent.js +4 -11
- package/lib/SyntheticKeyboardEvent.js +17 -19
- package/lib/SyntheticMouseEvent.js +5 -12
- package/lib/SyntheticTouchEvent.js +5 -12
- package/lib/SyntheticUIEvent.js +5 -12
- package/lib/SyntheticWheelEvent.js +5 -12
- package/lib/Transaction.js +5 -12
- package/lib/ViewportMetrics.js +5 -12
- package/lib/accumulateInto.js +62 -0
- package/lib/adler32.js +6 -13
- package/lib/camelize.js +30 -0
- package/lib/camelizeStyleName.js +40 -0
- package/lib/cloneWithProps.js +9 -15
- package/lib/containsNode.js +5 -12
- package/lib/copyProperties.js +12 -12
- package/lib/createArrayFrom.js +5 -12
- package/lib/createFullPageComponent.js +12 -18
- package/lib/createNodesFromMarkup.js +5 -12
- package/lib/cx.js +5 -12
- package/lib/dangerousStyleValue.js +5 -12
- package/lib/deprecated.js +47 -0
- package/lib/emptyFunction.js +11 -22
- package/lib/emptyObject.js +5 -12
- package/lib/escapeTextForBrowser.js +5 -12
- package/lib/flattenChildren.js +19 -13
- package/lib/focusNode.js +10 -16
- package/lib/forEachAccumulated.js +5 -12
- package/lib/getActiveElement.js +5 -12
- package/lib/getEventCharCode.js +50 -0
- package/lib/getEventKey.js +9 -21
- package/lib/getEventModifierState.js +4 -11
- package/lib/getEventTarget.js +5 -12
- package/lib/getMarkupWrap.js +5 -12
- package/lib/getNodeForCharacterOffset.js +5 -12
- package/lib/getReactRootElementInContainer.js +5 -12
- package/lib/getTextContentAccessor.js +5 -12
- package/lib/getUnboundedScrollPosition.js +5 -12
- package/lib/hyphenate.js +5 -12
- package/lib/hyphenateStyleName.js +8 -15
- package/lib/instantiateReactComponent.js +90 -42
- package/lib/invariant.js +5 -12
- package/lib/isEventSupported.js +5 -12
- package/lib/isNode.js +5 -12
- package/lib/isTextInputElement.js +5 -12
- package/lib/isTextNode.js +5 -12
- package/lib/joinClasses.js +8 -13
- package/lib/keyMirror.js +5 -12
- package/lib/keyOf.js +5 -12
- package/lib/mapObject.js +35 -36
- package/lib/memoizeStringOnly.js +5 -12
- package/lib/merge.js +14 -17
- package/lib/mergeInto.js +13 -35
- package/lib/monitorCodeUse.js +5 -12
- package/lib/onlyChild.js +8 -15
- package/lib/performance.js +5 -12
- package/lib/performanceNow.js +5 -12
- package/lib/setInnerHTML.js +10 -19
- package/lib/shallowEqual.js +6 -13
- package/lib/shouldUpdateReactComponent.js +14 -22
- package/lib/toArray.js +5 -12
- package/lib/traverseAllChildren.js +34 -48
- package/lib/update.js +8 -15
- package/lib/warning.js +6 -13
- package/package.json +3 -8
- package/lib/ReactDescriptor.js +0 -251
- package/lib/accumulate.js +0 -54
- package/lib/mergeHelpers.js +0 -147
- package/lib/mixInto.js +0 -34
package/lib/ReactDOMComponent.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
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.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactDOMComponent
|
|
17
10
|
* @typechecks static-only
|
|
@@ -29,11 +22,12 @@ var ReactMount = require("./ReactMount");
|
|
|
29
22
|
var ReactMultiChild = require("./ReactMultiChild");
|
|
30
23
|
var ReactPerf = require("./ReactPerf");
|
|
31
24
|
|
|
25
|
+
var assign = require("./Object.assign");
|
|
32
26
|
var escapeTextForBrowser = require("./escapeTextForBrowser");
|
|
33
27
|
var invariant = require("./invariant");
|
|
28
|
+
var isEventSupported = require("./isEventSupported");
|
|
34
29
|
var keyOf = require("./keyOf");
|
|
35
|
-
var
|
|
36
|
-
var mixInto = require("./mixInto");
|
|
30
|
+
var monitorCodeUse = require("./monitorCodeUse");
|
|
37
31
|
|
|
38
32
|
var deleteListener = ReactBrowserEventEmitter.deleteListener;
|
|
39
33
|
var listenTo = ReactBrowserEventEmitter.listenTo;
|
|
@@ -58,6 +52,16 @@ function assertValidProps(props) {
|
|
|
58
52
|
props.children == null || props.dangerouslySetInnerHTML == null,
|
|
59
53
|
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
|
|
60
54
|
) : invariant(props.children == null || props.dangerouslySetInnerHTML == null));
|
|
55
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
56
|
+
if (props.contentEditable && props.children != null) {
|
|
57
|
+
console.warn(
|
|
58
|
+
'A component is `contentEditable` and contains `children` managed by ' +
|
|
59
|
+
'React. It is now your responsibility to guarantee that none of those '+
|
|
60
|
+
'nodes are unexpectedly modified or duplicated. This is probably not ' +
|
|
61
|
+
'intentional.'
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
61
65
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
62
66
|
props.style == null || typeof props.style === 'object',
|
|
63
67
|
'The `style` prop expects a mapping from style properties to values, ' +
|
|
@@ -66,6 +70,15 @@ function assertValidProps(props) {
|
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
function putListener(id, registrationName, listener, transaction) {
|
|
73
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
74
|
+
// IE8 has no API for event capturing and the `onScroll` event doesn't
|
|
75
|
+
// bubble.
|
|
76
|
+
if (registrationName === 'onScroll' &&
|
|
77
|
+
!isEventSupported('scroll', true)) {
|
|
78
|
+
monitorCodeUse('react_no_scroll_event');
|
|
79
|
+
console.warn('This browser doesn\'t support the `onScroll` event');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
69
82
|
var container = ReactMount.findReactContainerForID(id);
|
|
70
83
|
if (container) {
|
|
71
84
|
var doc = container.nodeType === ELEMENT_NODE_TYPE ?
|
|
@@ -80,18 +93,66 @@ function putListener(id, registrationName, listener, transaction) {
|
|
|
80
93
|
);
|
|
81
94
|
}
|
|
82
95
|
|
|
96
|
+
// For HTML, certain tags should omit their close tag. We keep a whitelist for
|
|
97
|
+
// those special cased tags.
|
|
98
|
+
|
|
99
|
+
var omittedCloseTags = {
|
|
100
|
+
'area': true,
|
|
101
|
+
'base': true,
|
|
102
|
+
'br': true,
|
|
103
|
+
'col': true,
|
|
104
|
+
'embed': true,
|
|
105
|
+
'hr': true,
|
|
106
|
+
'img': true,
|
|
107
|
+
'input': true,
|
|
108
|
+
'keygen': true,
|
|
109
|
+
'link': true,
|
|
110
|
+
'meta': true,
|
|
111
|
+
'param': true,
|
|
112
|
+
'source': true,
|
|
113
|
+
'track': true,
|
|
114
|
+
'wbr': true
|
|
115
|
+
// NOTE: menuitem's close tag should be omitted, but that causes problems.
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// We accept any tag to be rendered but since this gets injected into abitrary
|
|
119
|
+
// HTML, we want to make sure that it's a safe tag.
|
|
120
|
+
// http://www.w3.org/TR/REC-xml/#NT-Name
|
|
121
|
+
|
|
122
|
+
var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
|
|
123
|
+
var validatedTagCache = {};
|
|
124
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
125
|
+
|
|
126
|
+
function validateDangerousTag(tag) {
|
|
127
|
+
if (!hasOwnProperty.call(validatedTagCache, tag)) {
|
|
128
|
+
("production" !== process.env.NODE_ENV ? invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag) : invariant(VALID_TAG_REGEX.test(tag)));
|
|
129
|
+
validatedTagCache[tag] = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
83
132
|
|
|
84
133
|
/**
|
|
134
|
+
* Creates a new React class that is idempotent and capable of containing other
|
|
135
|
+
* React components. It accepts event listeners and DOM properties that are
|
|
136
|
+
* valid according to `DOMProperty`.
|
|
137
|
+
*
|
|
138
|
+
* - Event listeners: `onClick`, `onMouseDown`, etc.
|
|
139
|
+
* - DOM properties: `className`, `name`, `title`, etc.
|
|
140
|
+
*
|
|
141
|
+
* The `style` property functions differently from the DOM API. It accepts an
|
|
142
|
+
* object mapping of style properties to values.
|
|
143
|
+
*
|
|
85
144
|
* @constructor ReactDOMComponent
|
|
86
145
|
* @extends ReactComponent
|
|
87
146
|
* @extends ReactMultiChild
|
|
88
147
|
*/
|
|
89
|
-
function ReactDOMComponent(tag
|
|
90
|
-
|
|
91
|
-
this.
|
|
148
|
+
function ReactDOMComponent(tag) {
|
|
149
|
+
validateDangerousTag(tag);
|
|
150
|
+
this._tag = tag;
|
|
92
151
|
this.tagName = tag.toUpperCase();
|
|
93
152
|
}
|
|
94
153
|
|
|
154
|
+
ReactDOMComponent.displayName = 'ReactDOMComponent';
|
|
155
|
+
|
|
95
156
|
ReactDOMComponent.Mixin = {
|
|
96
157
|
|
|
97
158
|
/**
|
|
@@ -115,10 +176,11 @@ ReactDOMComponent.Mixin = {
|
|
|
115
176
|
mountDepth
|
|
116
177
|
);
|
|
117
178
|
assertValidProps(this.props);
|
|
179
|
+
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
|
|
118
180
|
return (
|
|
119
181
|
this._createOpenTagMarkupAndPutListeners(transaction) +
|
|
120
182
|
this._createContentMarkup(transaction) +
|
|
121
|
-
|
|
183
|
+
closeTag
|
|
122
184
|
);
|
|
123
185
|
}
|
|
124
186
|
),
|
|
@@ -137,7 +199,7 @@ ReactDOMComponent.Mixin = {
|
|
|
137
199
|
*/
|
|
138
200
|
_createOpenTagMarkupAndPutListeners: function(transaction) {
|
|
139
201
|
var props = this.props;
|
|
140
|
-
var ret = this.
|
|
202
|
+
var ret = '<' + this._tag;
|
|
141
203
|
|
|
142
204
|
for (var propKey in props) {
|
|
143
205
|
if (!props.hasOwnProperty(propKey)) {
|
|
@@ -152,7 +214,7 @@ ReactDOMComponent.Mixin = {
|
|
|
152
214
|
} else {
|
|
153
215
|
if (propKey === STYLE) {
|
|
154
216
|
if (propValue) {
|
|
155
|
-
propValue = props.style =
|
|
217
|
+
propValue = props.style = assign({}, props.style);
|
|
156
218
|
}
|
|
157
219
|
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
|
|
158
220
|
}
|
|
@@ -205,22 +267,22 @@ ReactDOMComponent.Mixin = {
|
|
|
205
267
|
return '';
|
|
206
268
|
},
|
|
207
269
|
|
|
208
|
-
receiveComponent: function(
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
// Since
|
|
270
|
+
receiveComponent: function(nextElement, transaction) {
|
|
271
|
+
if (nextElement === this._currentElement &&
|
|
272
|
+
nextElement._owner != null) {
|
|
273
|
+
// Since elements are immutable after the owner is rendered,
|
|
212
274
|
// we can do a cheap identity compare here to determine if this is a
|
|
213
275
|
// superfluous reconcile. It's possible for state to be mutable but such
|
|
214
276
|
// change should trigger an update of the owner which would recreate
|
|
215
|
-
// the
|
|
216
|
-
// it's possible for a
|
|
277
|
+
// the element. We explicitly check for the existence of an owner since
|
|
278
|
+
// it's possible for a element created outside a composite to be
|
|
217
279
|
// deeply mutated and reused.
|
|
218
280
|
return;
|
|
219
281
|
}
|
|
220
282
|
|
|
221
283
|
ReactComponent.Mixin.receiveComponent.call(
|
|
222
284
|
this,
|
|
223
|
-
|
|
285
|
+
nextElement,
|
|
224
286
|
transaction
|
|
225
287
|
);
|
|
226
288
|
},
|
|
@@ -230,22 +292,22 @@ ReactDOMComponent.Mixin = {
|
|
|
230
292
|
* attached to the DOM. Reconciles the root DOM node, then recurses.
|
|
231
293
|
*
|
|
232
294
|
* @param {ReactReconcileTransaction} transaction
|
|
233
|
-
* @param {
|
|
295
|
+
* @param {ReactElement} prevElement
|
|
234
296
|
* @internal
|
|
235
297
|
* @overridable
|
|
236
298
|
*/
|
|
237
299
|
updateComponent: ReactPerf.measure(
|
|
238
300
|
'ReactDOMComponent',
|
|
239
301
|
'updateComponent',
|
|
240
|
-
function(transaction,
|
|
241
|
-
assertValidProps(this.
|
|
302
|
+
function(transaction, prevElement) {
|
|
303
|
+
assertValidProps(this._currentElement.props);
|
|
242
304
|
ReactComponent.Mixin.updateComponent.call(
|
|
243
305
|
this,
|
|
244
306
|
transaction,
|
|
245
|
-
|
|
307
|
+
prevElement
|
|
246
308
|
);
|
|
247
|
-
this._updateDOMProperties(
|
|
248
|
-
this._updateDOMChildren(
|
|
309
|
+
this._updateDOMProperties(prevElement.props, transaction);
|
|
310
|
+
this._updateDOMChildren(prevElement.props, transaction);
|
|
249
311
|
}
|
|
250
312
|
),
|
|
251
313
|
|
|
@@ -301,7 +363,7 @@ ReactDOMComponent.Mixin = {
|
|
|
301
363
|
}
|
|
302
364
|
if (propKey === STYLE) {
|
|
303
365
|
if (nextProp) {
|
|
304
|
-
nextProp = nextProps.style =
|
|
366
|
+
nextProp = nextProps.style = assign({}, nextProp);
|
|
305
367
|
}
|
|
306
368
|
if (lastProp) {
|
|
307
369
|
// Unset styles on `lastProp` but not on `nextProp`.
|
|
@@ -410,9 +472,12 @@ ReactDOMComponent.Mixin = {
|
|
|
410
472
|
|
|
411
473
|
};
|
|
412
474
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
475
|
+
assign(
|
|
476
|
+
ReactDOMComponent.prototype,
|
|
477
|
+
ReactComponent.Mixin,
|
|
478
|
+
ReactDOMComponent.Mixin,
|
|
479
|
+
ReactMultiChild.Mixin,
|
|
480
|
+
ReactBrowserComponentMixin
|
|
481
|
+
);
|
|
417
482
|
|
|
418
483
|
module.exports = ReactDOMComponent;
|
package/lib/ReactDOMForm.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
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.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactDOMForm
|
|
17
10
|
*/
|
|
@@ -22,10 +15,11 @@ var EventConstants = require("./EventConstants");
|
|
|
22
15
|
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
|
|
23
16
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
24
17
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
18
|
+
var ReactElement = require("./ReactElement");
|
|
25
19
|
var ReactDOM = require("./ReactDOM");
|
|
26
20
|
|
|
27
|
-
// Store a reference to the <form> `ReactDOMComponent`.
|
|
28
|
-
var form = ReactDOM.form;
|
|
21
|
+
// Store a reference to the <form> `ReactDOMComponent`. TODO: use string
|
|
22
|
+
var form = ReactElement.createFactory(ReactDOM.form.type);
|
|
29
23
|
|
|
30
24
|
/**
|
|
31
25
|
* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
|
|
@@ -42,7 +36,7 @@ var ReactDOMForm = ReactCompositeComponent.createClass({
|
|
|
42
36
|
// TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
|
|
43
37
|
// `jshint` fails to parse JSX so in order for linting to work in the open
|
|
44
38
|
// source repo, we need to just use `ReactDOM.form`.
|
|
45
|
-
return
|
|
39
|
+
return form(this.props);
|
|
46
40
|
},
|
|
47
41
|
|
|
48
42
|
componentDidMount: function() {
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
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.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactDOMIDOperations
|
|
17
10
|
* @typechecks static-only
|
package/lib/ReactDOMImg.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
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.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactDOMImg
|
|
17
10
|
*/
|
|
@@ -22,10 +15,11 @@ var EventConstants = require("./EventConstants");
|
|
|
22
15
|
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
|
|
23
16
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
24
17
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
18
|
+
var ReactElement = require("./ReactElement");
|
|
25
19
|
var ReactDOM = require("./ReactDOM");
|
|
26
20
|
|
|
27
|
-
// Store a reference to the <img> `ReactDOMComponent`.
|
|
28
|
-
var img = ReactDOM.img;
|
|
21
|
+
// Store a reference to the <img> `ReactDOMComponent`. TODO: use string
|
|
22
|
+
var img = ReactElement.createFactory(ReactDOM.img.type);
|
|
29
23
|
|
|
30
24
|
/**
|
|
31
25
|
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
|
package/lib/ReactDOMInput.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
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.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactDOMInput
|
|
17
10
|
*/
|
|
@@ -23,17 +16,26 @@ var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
|
23
16
|
var LinkedValueUtils = require("./LinkedValueUtils");
|
|
24
17
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
25
18
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
19
|
+
var ReactElement = require("./ReactElement");
|
|
26
20
|
var ReactDOM = require("./ReactDOM");
|
|
27
21
|
var ReactMount = require("./ReactMount");
|
|
22
|
+
var ReactUpdates = require("./ReactUpdates");
|
|
28
23
|
|
|
24
|
+
var assign = require("./Object.assign");
|
|
29
25
|
var invariant = require("./invariant");
|
|
30
|
-
var merge = require("./merge");
|
|
31
26
|
|
|
32
|
-
// Store a reference to the <input> `ReactDOMComponent`.
|
|
33
|
-
var input = ReactDOM.input;
|
|
27
|
+
// Store a reference to the <input> `ReactDOMComponent`. TODO: use string
|
|
28
|
+
var input = ReactElement.createFactory(ReactDOM.input.type);
|
|
34
29
|
|
|
35
30
|
var instancesByReactID = {};
|
|
36
31
|
|
|
32
|
+
function forceUpdateIfMounted() {
|
|
33
|
+
/*jshint validthis:true */
|
|
34
|
+
if (this.isMounted()) {
|
|
35
|
+
this.forceUpdate();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
37
39
|
/**
|
|
38
40
|
* Implements an <input> native component that allows setting these optional
|
|
39
41
|
* props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
|
|
@@ -58,28 +60,23 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
|
|
|
58
60
|
getInitialState: function() {
|
|
59
61
|
var defaultValue = this.props.defaultValue;
|
|
60
62
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
initialChecked: this.props.defaultChecked || false,
|
|
64
|
+
initialValue: defaultValue != null ? defaultValue : null
|
|
63
65
|
};
|
|
64
66
|
},
|
|
65
67
|
|
|
66
|
-
shouldComponentUpdate: function() {
|
|
67
|
-
// Defer any updates to this component during the `onChange` handler.
|
|
68
|
-
return !this._isChanging;
|
|
69
|
-
},
|
|
70
|
-
|
|
71
68
|
render: function() {
|
|
72
69
|
// Clone `this.props` so we don't mutate the input.
|
|
73
|
-
var props =
|
|
70
|
+
var props = assign({}, this.props);
|
|
74
71
|
|
|
75
72
|
props.defaultChecked = null;
|
|
76
73
|
props.defaultValue = null;
|
|
77
74
|
|
|
78
75
|
var value = LinkedValueUtils.getValue(this);
|
|
79
|
-
props.value = value != null ? value : this.state.
|
|
76
|
+
props.value = value != null ? value : this.state.initialValue;
|
|
80
77
|
|
|
81
78
|
var checked = LinkedValueUtils.getChecked(this);
|
|
82
|
-
props.checked = checked != null ? checked : this.state.
|
|
79
|
+
props.checked = checked != null ? checked : this.state.initialChecked;
|
|
83
80
|
|
|
84
81
|
props.onChange = this._handleChange;
|
|
85
82
|
|
|
@@ -119,14 +116,12 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
|
|
|
119
116
|
var returnValue;
|
|
120
117
|
var onChange = LinkedValueUtils.getOnChange(this);
|
|
121
118
|
if (onChange) {
|
|
122
|
-
this._isChanging = true;
|
|
123
119
|
returnValue = onChange.call(this, event);
|
|
124
|
-
this._isChanging = false;
|
|
125
120
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
// Here we use asap to wait until all updates have propagated, which
|
|
122
|
+
// is important when using controlled components within layers:
|
|
123
|
+
// https://github.com/facebook/react/issues/1698
|
|
124
|
+
ReactUpdates.asap(forceUpdateIfMounted, this);
|
|
130
125
|
|
|
131
126
|
var name = this.props.name;
|
|
132
127
|
if (this.props.type === 'radio' && name != null) {
|
|
@@ -164,13 +159,10 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
|
|
|
164
159
|
'ReactDOMInput: Unknown radio button ID %s.',
|
|
165
160
|
otherID
|
|
166
161
|
) : invariant(otherInstance));
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
otherInstance.setState({
|
|
172
|
-
checked: false
|
|
173
|
-
});
|
|
162
|
+
// If this is a controlled radio button group, forcing the input that
|
|
163
|
+
// was previously checked to update will cause it to be come re-checked
|
|
164
|
+
// as appropriate.
|
|
165
|
+
ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
|
|
174
166
|
}
|
|
175
167
|
}
|
|
176
168
|
|