react 0.13.1 → 0.14.0-alpha2
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 +1 -1
- package/addons.js +7 -0
- package/addons/CSSTransitionGroup.js +1 -0
- package/addons/LinkedStateMixin.js +1 -0
- package/addons/Perf.js +1 -0
- package/addons/PureRenderMixin.js +1 -0
- package/addons/TestUtils.js +1 -0
- package/addons/TransitionGroup.js +1 -0
- package/addons/batchedUpdates.js +1 -0
- package/addons/cloneWithProps.js +1 -0
- package/addons/createFragment.js +1 -0
- package/addons/renderSubtreeIntoContainer.js +1 -0
- package/addons/shallowCompare.js +1 -0
- package/addons/update.js +1 -0
- package/dist/JSXTransformer.js +3336 -1671
- package/dist/react-with-addons.js +3320 -5125
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +2952 -4533
- package/dist/react.min.js +5 -5
- package/lib/AutoFocusMixin.js +4 -3
- package/lib/BeforeInputEventPlugin.js +30 -118
- package/lib/CSSCore.js +12 -23
- package/lib/CSSProperty.js +9 -4
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +24 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +41 -67
- package/lib/DOMPropertyOperations.js +30 -51
- package/lib/Danger.js +19 -62
- package/lib/DefaultEventPluginOrder.js +2 -12
- package/lib/EnterLeaveEventPlugin.js +11 -33
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +11 -13
- package/lib/EventPluginHub.js +44 -47
- package/lib/EventPluginRegistry.js +18 -74
- package/lib/EventPluginUtils.js +27 -38
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +13 -20
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +34 -64
- package/lib/LocalEventTrapMixin.js +9 -16
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +8 -11
- package/lib/React.js +9 -129
- package/lib/ReactBrowserComponentMixin.js +9 -2
- package/lib/ReactBrowserEventEmitter.js +26 -82
- package/lib/ReactCSSTransitionGroup.js +13 -24
- package/lib/ReactCSSTransitionGroupChild.js +18 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +21 -28
- package/lib/ReactClass.js +81 -234
- package/lib/ReactComponent.js +17 -33
- package/lib/ReactComponentBrowserEnvironment.js +4 -8
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +4 -5
- package/lib/ReactCompositeComponent.js +85 -297
- package/lib/ReactContext.js +2 -44
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +4 -2
- package/lib/ReactDOMButton.js +3 -4
- package/lib/ReactDOMClient.js +85 -0
- package/lib/ReactDOMComponent.js +184 -146
- package/lib/ReactDOMForm.js +3 -3
- package/lib/ReactDOMIDOperations.js +11 -22
- package/lib/ReactDOMIframe.js +3 -3
- package/lib/ReactDOMImg.js +3 -3
- package/lib/ReactDOMInput.js +22 -35
- package/lib/ReactDOMOption.js +68 -10
- package/lib/ReactDOMSelect.js +50 -28
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +15 -27
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +31 -40
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +24 -57
- package/lib/ReactElementValidator.js +38 -105
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +2 -2
- package/lib/ReactEventEmitterMixin.js +3 -12
- package/lib/ReactEventListener.js +16 -38
- package/lib/ReactFragment.js +23 -54
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +11 -21
- package/lib/ReactInstanceHandles.js +27 -57
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLifeCycle.js +1 -1
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +137 -260
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +7 -11
- package/lib/ReactOwner.js +7 -24
- package/lib/ReactPerf.js +8 -12
- package/lib/ReactPropTransferer.js +4 -4
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +29 -61
- package/lib/ReactReconcileTransaction.js +9 -34
- package/lib/ReactReconciler.js +9 -19
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +7 -15
- package/lib/ReactServerRenderingTransaction.js +7 -32
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +93 -165
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +27 -90
- package/lib/ReactUpdates.js +27 -79
- package/lib/ReactWithAddons.js +7 -6
- package/lib/SVGDOMPropertyConfig.js +41 -4
- package/lib/SelectEventPlugin.js +28 -29
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +136 -128
- package/lib/SyntheticClipboardEvent.js +3 -7
- package/lib/SyntheticCompositionEvent.js +3 -9
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +8 -10
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +3 -9
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +8 -14
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +3 -3
- package/lib/SyntheticWheelEvent.js +11 -15
- package/lib/Transaction.js +12 -24
- package/lib/ViewportMetrics.js +2 -2
- package/lib/accumulateInto.js +2 -5
- package/lib/adler32.js +2 -4
- package/lib/camelize.js +4 -2
- package/lib/camelizeStyleName.js +2 -2
- package/lib/cloneWithProps.js +5 -11
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createFullPageComponent.js +4 -11
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +5 -24
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +2 -2
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -1
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +7 -5
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getTextContentAccessor.js +2 -4
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +3 -1
- package/lib/hyphenateStyleName.js +2 -2
- package/lib/instantiateReactComponent.js +14 -37
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +2 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +2 -2
- package/lib/keyMirror.js +3 -6
- package/lib/keyOf.js +4 -3
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +2 -2
- package/lib/onlyChild.js +2 -5
- package/lib/performance.js +2 -5
- package/lib/performanceNow.js +3 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +16 -0
- package/lib/setInnerHTML.js +11 -8
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +24 -0
- package/lib/shallowEqual.js +17 -11
- package/lib/shouldUpdateReactComponent.js +3 -64
- package/lib/toArray.js +8 -19
- package/lib/traverseAllChildren.js +22 -89
- package/lib/update.js +33 -90
- package/lib/validateDOMNesting.js +355 -0
- package/lib/warning.js +17 -15
- package/package.json +3 -3
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
package/lib/CallbackQueue.js
CHANGED
|
@@ -41,7 +41,7 @@ assign(CallbackQueue.prototype, {
|
|
|
41
41
|
* @param {?object} context Context to call `callback` with.
|
|
42
42
|
* @internal
|
|
43
43
|
*/
|
|
44
|
-
enqueue: function(callback, context) {
|
|
44
|
+
enqueue: function (callback, context) {
|
|
45
45
|
this._callbacks = this._callbacks || [];
|
|
46
46
|
this._contexts = this._contexts || [];
|
|
47
47
|
this._callbacks.push(callback);
|
|
@@ -54,17 +54,14 @@ assign(CallbackQueue.prototype, {
|
|
|
54
54
|
*
|
|
55
55
|
* @internal
|
|
56
56
|
*/
|
|
57
|
-
notifyAll: function() {
|
|
57
|
+
notifyAll: function () {
|
|
58
58
|
var callbacks = this._callbacks;
|
|
59
59
|
var contexts = this._contexts;
|
|
60
60
|
if (callbacks) {
|
|
61
|
-
|
|
62
|
-
callbacks.length === contexts.length,
|
|
63
|
-
'Mismatched list of contexts in callback queue'
|
|
64
|
-
) : invariant(callbacks.length === contexts.length));
|
|
61
|
+
'production' !== process.env.NODE_ENV ? invariant(callbacks.length === contexts.length, 'Mismatched list of contexts in callback queue') : invariant(callbacks.length === contexts.length);
|
|
65
62
|
this._callbacks = null;
|
|
66
63
|
this._contexts = null;
|
|
67
|
-
for (var i = 0
|
|
64
|
+
for (var i = 0; i < callbacks.length; i++) {
|
|
68
65
|
callbacks[i].call(contexts[i]);
|
|
69
66
|
}
|
|
70
67
|
callbacks.length = 0;
|
|
@@ -77,7 +74,7 @@ assign(CallbackQueue.prototype, {
|
|
|
77
74
|
*
|
|
78
75
|
* @internal
|
|
79
76
|
*/
|
|
80
|
-
reset: function() {
|
|
77
|
+
reset: function () {
|
|
81
78
|
this._callbacks = null;
|
|
82
79
|
this._contexts = null;
|
|
83
80
|
},
|
|
@@ -85,7 +82,7 @@ assign(CallbackQueue.prototype, {
|
|
|
85
82
|
/**
|
|
86
83
|
* `PooledClass` looks for this.
|
|
87
84
|
*/
|
|
88
|
-
destructor: function() {
|
|
85
|
+
destructor: function () {
|
|
89
86
|
this.reset();
|
|
90
87
|
}
|
|
91
88
|
|
|
@@ -93,4 +90,4 @@ assign(CallbackQueue.prototype, {
|
|
|
93
90
|
|
|
94
91
|
PooledClass.addPoolingTo(CallbackQueue);
|
|
95
92
|
|
|
96
|
-
module.exports = CallbackQueue;
|
|
93
|
+
module.exports = CallbackQueue;
|
package/lib/ChangeEventPlugin.js
CHANGED
|
@@ -27,19 +27,10 @@ var topLevelTypes = EventConstants.topLevelTypes;
|
|
|
27
27
|
var eventTypes = {
|
|
28
28
|
change: {
|
|
29
29
|
phasedRegistrationNames: {
|
|
30
|
-
bubbled: keyOf({onChange: null}),
|
|
31
|
-
captured: keyOf({onChangeCapture: null})
|
|
30
|
+
bubbled: keyOf({ onChange: null }),
|
|
31
|
+
captured: keyOf({ onChangeCapture: null })
|
|
32
32
|
},
|
|
33
|
-
dependencies: [
|
|
34
|
-
topLevelTypes.topBlur,
|
|
35
|
-
topLevelTypes.topChange,
|
|
36
|
-
topLevelTypes.topClick,
|
|
37
|
-
topLevelTypes.topFocus,
|
|
38
|
-
topLevelTypes.topInput,
|
|
39
|
-
topLevelTypes.topKeyDown,
|
|
40
|
-
topLevelTypes.topKeyUp,
|
|
41
|
-
topLevelTypes.topSelectionChange
|
|
42
|
-
]
|
|
33
|
+
dependencies: [topLevelTypes.topBlur, topLevelTypes.topChange, topLevelTypes.topClick, topLevelTypes.topFocus, topLevelTypes.topInput, topLevelTypes.topKeyDown, topLevelTypes.topKeyUp, topLevelTypes.topSelectionChange]
|
|
43
34
|
}
|
|
44
35
|
};
|
|
45
36
|
|
|
@@ -55,26 +46,17 @@ var activeElementValueProp = null;
|
|
|
55
46
|
* SECTION: handle `change` event
|
|
56
47
|
*/
|
|
57
48
|
function shouldUseChangeEvent(elem) {
|
|
58
|
-
return
|
|
59
|
-
elem.nodeName === 'SELECT' ||
|
|
60
|
-
(elem.nodeName === 'INPUT' && elem.type === 'file')
|
|
61
|
-
);
|
|
49
|
+
return elem.nodeName === 'SELECT' || elem.nodeName === 'INPUT' && elem.type === 'file';
|
|
62
50
|
}
|
|
63
51
|
|
|
64
52
|
var doesChangeEventBubble = false;
|
|
65
53
|
if (ExecutionEnvironment.canUseDOM) {
|
|
66
54
|
// See `handleChange` comment below
|
|
67
|
-
doesChangeEventBubble = isEventSupported('change') && (
|
|
68
|
-
(!('documentMode' in document) || document.documentMode > 8)
|
|
69
|
-
);
|
|
55
|
+
doesChangeEventBubble = isEventSupported('change') && (!('documentMode' in document) || document.documentMode > 8);
|
|
70
56
|
}
|
|
71
57
|
|
|
72
58
|
function manualDispatchChangeEvent(nativeEvent) {
|
|
73
|
-
var event = SyntheticEvent.getPooled(
|
|
74
|
-
eventTypes.change,
|
|
75
|
-
activeElementID,
|
|
76
|
-
nativeEvent
|
|
77
|
-
);
|
|
59
|
+
var event = SyntheticEvent.getPooled(eventTypes.change, activeElementID, nativeEvent);
|
|
78
60
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
79
61
|
|
|
80
62
|
// If change and propertychange bubbled, we'd just bind to it like all the
|
|
@@ -111,18 +93,12 @@ function stopWatchingForChangeEventIE8() {
|
|
|
111
93
|
activeElementID = null;
|
|
112
94
|
}
|
|
113
95
|
|
|
114
|
-
function getTargetIDForChangeEvent(
|
|
115
|
-
topLevelType,
|
|
116
|
-
topLevelTarget,
|
|
117
|
-
topLevelTargetID) {
|
|
96
|
+
function getTargetIDForChangeEvent(topLevelType, topLevelTarget, topLevelTargetID) {
|
|
118
97
|
if (topLevelType === topLevelTypes.topChange) {
|
|
119
98
|
return topLevelTargetID;
|
|
120
99
|
}
|
|
121
100
|
}
|
|
122
|
-
function handleEventsForChangeEventIE8(
|
|
123
|
-
topLevelType,
|
|
124
|
-
topLevelTarget,
|
|
125
|
-
topLevelTargetID) {
|
|
101
|
+
function handleEventsForChangeEventIE8(topLevelType, topLevelTarget, topLevelTargetID) {
|
|
126
102
|
if (topLevelType === topLevelTypes.topFocus) {
|
|
127
103
|
// stopWatching() should be a noop here but we call it just in case we
|
|
128
104
|
// missed a blur event somehow.
|
|
@@ -133,7 +109,6 @@ function handleEventsForChangeEventIE8(
|
|
|
133
109
|
}
|
|
134
110
|
}
|
|
135
111
|
|
|
136
|
-
|
|
137
112
|
/**
|
|
138
113
|
* SECTION: handle `input` event
|
|
139
114
|
*/
|
|
@@ -141,20 +116,18 @@ var isInputEventSupported = false;
|
|
|
141
116
|
if (ExecutionEnvironment.canUseDOM) {
|
|
142
117
|
// IE9 claims to support the input event but fails to trigger it when
|
|
143
118
|
// deleting text, so we ignore its input events
|
|
144
|
-
isInputEventSupported = isEventSupported('input') && (
|
|
145
|
-
(!('documentMode' in document) || document.documentMode > 9)
|
|
146
|
-
);
|
|
119
|
+
isInputEventSupported = isEventSupported('input') && (!('documentMode' in document) || document.documentMode > 9);
|
|
147
120
|
}
|
|
148
121
|
|
|
149
122
|
/**
|
|
150
123
|
* (For old IE.) Replacement getter/setter for the `value` property that gets
|
|
151
124
|
* set on the active element.
|
|
152
125
|
*/
|
|
153
|
-
var newValueProp =
|
|
154
|
-
get: function() {
|
|
126
|
+
var newValueProp = {
|
|
127
|
+
get: function () {
|
|
155
128
|
return activeElementValueProp.get.call(this);
|
|
156
129
|
},
|
|
157
|
-
set: function(val) {
|
|
130
|
+
set: function (val) {
|
|
158
131
|
// Cast to a string so we can do equality checks.
|
|
159
132
|
activeElementValue = '' + val;
|
|
160
133
|
activeElementValueProp.set.call(this, val);
|
|
@@ -170,10 +143,7 @@ function startWatchingForValueChange(target, targetID) {
|
|
|
170
143
|
activeElement = target;
|
|
171
144
|
activeElementID = targetID;
|
|
172
145
|
activeElementValue = target.value;
|
|
173
|
-
activeElementValueProp = Object.getOwnPropertyDescriptor(
|
|
174
|
-
target.constructor.prototype,
|
|
175
|
-
'value'
|
|
176
|
-
);
|
|
146
|
+
activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value');
|
|
177
147
|
|
|
178
148
|
Object.defineProperty(activeElement, 'value', newValueProp);
|
|
179
149
|
activeElement.attachEvent('onpropertychange', handlePropertyChange);
|
|
@@ -218,10 +188,7 @@ function handlePropertyChange(nativeEvent) {
|
|
|
218
188
|
/**
|
|
219
189
|
* If a `change` event should be fired, returns the target's ID.
|
|
220
190
|
*/
|
|
221
|
-
function getTargetIDForInputEvent(
|
|
222
|
-
topLevelType,
|
|
223
|
-
topLevelTarget,
|
|
224
|
-
topLevelTargetID) {
|
|
191
|
+
function getTargetIDForInputEvent(topLevelType, topLevelTarget, topLevelTargetID) {
|
|
225
192
|
if (topLevelType === topLevelTypes.topInput) {
|
|
226
193
|
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
|
|
227
194
|
// what we want so fall through here and trigger an abstract event
|
|
@@ -230,10 +197,7 @@ function getTargetIDForInputEvent(
|
|
|
230
197
|
}
|
|
231
198
|
|
|
232
199
|
// For IE8 and IE9.
|
|
233
|
-
function handleEventsForInputEventIE(
|
|
234
|
-
topLevelType,
|
|
235
|
-
topLevelTarget,
|
|
236
|
-
topLevelTargetID) {
|
|
200
|
+
function handleEventsForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
|
|
237
201
|
if (topLevelType === topLevelTypes.topFocus) {
|
|
238
202
|
// In IE8, we can capture almost all .value changes by adding a
|
|
239
203
|
// propertychange handler and looking for events with propertyName
|
|
@@ -256,13 +220,8 @@ function handleEventsForInputEventIE(
|
|
|
256
220
|
}
|
|
257
221
|
|
|
258
222
|
// For IE8 and IE9.
|
|
259
|
-
function getTargetIDForInputEventIE(
|
|
260
|
-
|
|
261
|
-
topLevelTarget,
|
|
262
|
-
topLevelTargetID) {
|
|
263
|
-
if (topLevelType === topLevelTypes.topSelectionChange ||
|
|
264
|
-
topLevelType === topLevelTypes.topKeyUp ||
|
|
265
|
-
topLevelType === topLevelTypes.topKeyDown) {
|
|
223
|
+
function getTargetIDForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
|
|
224
|
+
if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) {
|
|
266
225
|
// On the selectionchange event, the target is just document which isn't
|
|
267
226
|
// helpful for us so just check activeElement instead.
|
|
268
227
|
//
|
|
@@ -280,7 +239,6 @@ function getTargetIDForInputEventIE(
|
|
|
280
239
|
}
|
|
281
240
|
}
|
|
282
241
|
|
|
283
|
-
|
|
284
242
|
/**
|
|
285
243
|
* SECTION: handle `click` event
|
|
286
244
|
*/
|
|
@@ -288,16 +246,10 @@ function shouldUseClickEvent(elem) {
|
|
|
288
246
|
// Use the `click` event to detect changes to checkbox and radio inputs.
|
|
289
247
|
// This approach works across all browsers, whereas `change` does not fire
|
|
290
248
|
// until `blur` in IE8.
|
|
291
|
-
return (
|
|
292
|
-
elem.nodeName === 'INPUT' &&
|
|
293
|
-
(elem.type === 'checkbox' || elem.type === 'radio')
|
|
294
|
-
);
|
|
249
|
+
return elem.nodeName === 'INPUT' && (elem.type === 'checkbox' || elem.type === 'radio');
|
|
295
250
|
}
|
|
296
251
|
|
|
297
|
-
function getTargetIDForClickEvent(
|
|
298
|
-
topLevelType,
|
|
299
|
-
topLevelTarget,
|
|
300
|
-
topLevelTargetID) {
|
|
252
|
+
function getTargetIDForClickEvent(topLevelType, topLevelTarget, topLevelTargetID) {
|
|
301
253
|
if (topLevelType === topLevelTypes.topClick) {
|
|
302
254
|
return topLevelTargetID;
|
|
303
255
|
}
|
|
@@ -325,11 +277,7 @@ var ChangeEventPlugin = {
|
|
|
325
277
|
* @return {*} An accumulation of synthetic events.
|
|
326
278
|
* @see {EventPluginHub.extractEvents}
|
|
327
279
|
*/
|
|
328
|
-
extractEvents: function(
|
|
329
|
-
topLevelType,
|
|
330
|
-
topLevelTarget,
|
|
331
|
-
topLevelTargetID,
|
|
332
|
-
nativeEvent) {
|
|
280
|
+
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
|
|
333
281
|
|
|
334
282
|
var getTargetIDFunc, handleEventFunc;
|
|
335
283
|
if (shouldUseChangeEvent(topLevelTarget)) {
|
|
@@ -350,31 +298,19 @@ var ChangeEventPlugin = {
|
|
|
350
298
|
}
|
|
351
299
|
|
|
352
300
|
if (getTargetIDFunc) {
|
|
353
|
-
var targetID = getTargetIDFunc(
|
|
354
|
-
topLevelType,
|
|
355
|
-
topLevelTarget,
|
|
356
|
-
topLevelTargetID
|
|
357
|
-
);
|
|
301
|
+
var targetID = getTargetIDFunc(topLevelType, topLevelTarget, topLevelTargetID);
|
|
358
302
|
if (targetID) {
|
|
359
|
-
var event = SyntheticEvent.getPooled(
|
|
360
|
-
eventTypes.change,
|
|
361
|
-
targetID,
|
|
362
|
-
nativeEvent
|
|
363
|
-
);
|
|
303
|
+
var event = SyntheticEvent.getPooled(eventTypes.change, targetID, nativeEvent);
|
|
364
304
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
365
305
|
return event;
|
|
366
306
|
}
|
|
367
307
|
}
|
|
368
308
|
|
|
369
309
|
if (handleEventFunc) {
|
|
370
|
-
handleEventFunc(
|
|
371
|
-
topLevelType,
|
|
372
|
-
topLevelTarget,
|
|
373
|
-
topLevelTargetID
|
|
374
|
-
);
|
|
310
|
+
handleEventFunc(topLevelType, topLevelTarget, topLevelTargetID);
|
|
375
311
|
}
|
|
376
312
|
}
|
|
377
313
|
|
|
378
314
|
};
|
|
379
315
|
|
|
380
|
-
module.exports = ChangeEventPlugin;
|
|
316
|
+
module.exports = ChangeEventPlugin;
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
var nextReactRootIndex = 0;
|
|
16
16
|
|
|
17
17
|
var ClientReactRootIndex = {
|
|
18
|
-
createReactRootIndex: function() {
|
|
18
|
+
createReactRootIndex: function () {
|
|
19
19
|
return nextReactRootIndex++;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
module.exports = ClientReactRootIndex;
|
|
23
|
+
module.exports = ClientReactRootIndex;
|
|
@@ -31,10 +31,12 @@ function insertChildAt(parentNode, childNode, index) {
|
|
|
31
31
|
// rely exclusively on `insertBefore(node, null)` instead of also using
|
|
32
32
|
// `appendChild(node)`. However, using `undefined` is not allowed by all
|
|
33
33
|
// browsers so we must replace it with `null`.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
34
|
+
|
|
35
|
+
// fix render order error in safari
|
|
36
|
+
// IE8 will throw error when index out of list size.
|
|
37
|
+
var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index);
|
|
38
|
+
|
|
39
|
+
parentNode.insertBefore(childNode, beforeChild);
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
/**
|
|
@@ -54,7 +56,7 @@ var DOMChildrenOperations = {
|
|
|
54
56
|
* @param {array<string>} markupList List of markup strings.
|
|
55
57
|
* @internal
|
|
56
58
|
*/
|
|
57
|
-
processUpdates: function(updates, markupList) {
|
|
59
|
+
processUpdates: function (updates, markupList) {
|
|
58
60
|
var update;
|
|
59
61
|
// Mapping from parent IDs to initial child orderings.
|
|
60
62
|
var initialChildren = null;
|
|
@@ -63,23 +65,12 @@ var DOMChildrenOperations = {
|
|
|
63
65
|
|
|
64
66
|
for (var i = 0; i < updates.length; i++) {
|
|
65
67
|
update = updates[i];
|
|
66
|
-
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
|
|
67
|
-
update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
|
|
68
|
+
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING || update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
|
|
68
69
|
var updatedIndex = update.fromIndex;
|
|
69
70
|
var updatedChild = update.parentNode.childNodes[updatedIndex];
|
|
70
71
|
var parentID = update.parentID;
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
updatedChild,
|
|
74
|
-
'processUpdates(): Unable to find child %s of element. This ' +
|
|
75
|
-
'probably means the DOM was unexpectedly mutated (e.g., by the ' +
|
|
76
|
-
'browser), usually due to forgetting a <tbody> when using tables, ' +
|
|
77
|
-
'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' +
|
|
78
|
-
'in an <svg> parent. Try inspecting the child nodes of the element ' +
|
|
79
|
-
'with React ID `%s`.',
|
|
80
|
-
updatedIndex,
|
|
81
|
-
parentID
|
|
82
|
-
) : invariant(updatedChild));
|
|
73
|
+
'production' !== process.env.NODE_ENV ? invariant(updatedChild, 'processUpdates(): Unable to find child %s of element. This ' + 'probably means the DOM was unexpectedly mutated (e.g., by the ' + 'browser), usually due to forgetting a <tbody> when using tables, ' + 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' + 'in an <svg> parent. Try inspecting the child nodes of the element ' + 'with React ID `%s`.', updatedIndex, parentID) : invariant(updatedChild);
|
|
83
74
|
|
|
84
75
|
initialChildren = initialChildren || {};
|
|
85
76
|
initialChildren[parentID] = initialChildren[parentID] || [];
|
|
@@ -103,24 +94,13 @@ var DOMChildrenOperations = {
|
|
|
103
94
|
update = updates[k];
|
|
104
95
|
switch (update.type) {
|
|
105
96
|
case ReactMultiChildUpdateTypes.INSERT_MARKUP:
|
|
106
|
-
insertChildAt(
|
|
107
|
-
update.parentNode,
|
|
108
|
-
renderedMarkup[update.markupIndex],
|
|
109
|
-
update.toIndex
|
|
110
|
-
);
|
|
97
|
+
insertChildAt(update.parentNode, renderedMarkup[update.markupIndex], update.toIndex);
|
|
111
98
|
break;
|
|
112
99
|
case ReactMultiChildUpdateTypes.MOVE_EXISTING:
|
|
113
|
-
insertChildAt(
|
|
114
|
-
update.parentNode,
|
|
115
|
-
initialChildren[update.parentID][update.fromIndex],
|
|
116
|
-
update.toIndex
|
|
117
|
-
);
|
|
100
|
+
insertChildAt(update.parentNode, initialChildren[update.parentID][update.fromIndex], update.toIndex);
|
|
118
101
|
break;
|
|
119
102
|
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
|
|
120
|
-
setTextContent(
|
|
121
|
-
update.parentNode,
|
|
122
|
-
update.textContent
|
|
123
|
-
);
|
|
103
|
+
setTextContent(update.parentNode, update.textContent);
|
|
124
104
|
break;
|
|
125
105
|
case ReactMultiChildUpdateTypes.REMOVE_NODE:
|
|
126
106
|
// Already removed by the for-loop above.
|
|
@@ -131,4 +111,4 @@ var DOMChildrenOperations = {
|
|
|
131
111
|
|
|
132
112
|
};
|
|
133
113
|
|
|
134
|
-
module.exports = DOMChildrenOperations;
|
|
114
|
+
module.exports = DOMChildrenOperations;
|
package/lib/DOMProperty.js
CHANGED
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
* @typechecks static-only
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
/*jslint bitwise: true */
|
|
14
|
-
|
|
15
13
|
'use strict';
|
|
16
14
|
|
|
17
15
|
var invariant = require("./invariant");
|
|
@@ -25,13 +23,13 @@ var DOMPropertyInjection = {
|
|
|
25
23
|
* Mapping from normalized, camelcased property names to a configuration that
|
|
26
24
|
* specifies how the associated DOM property should be accessed or rendered.
|
|
27
25
|
*/
|
|
28
|
-
MUST_USE_ATTRIBUTE:
|
|
29
|
-
MUST_USE_PROPERTY:
|
|
30
|
-
HAS_SIDE_EFFECTS:
|
|
31
|
-
HAS_BOOLEAN_VALUE:
|
|
32
|
-
HAS_NUMERIC_VALUE:
|
|
33
|
-
HAS_POSITIVE_NUMERIC_VALUE:
|
|
34
|
-
HAS_OVERLOADED_BOOLEAN_VALUE:
|
|
26
|
+
MUST_USE_ATTRIBUTE: 1,
|
|
27
|
+
MUST_USE_PROPERTY: 2,
|
|
28
|
+
HAS_SIDE_EFFECTS: 4,
|
|
29
|
+
HAS_BOOLEAN_VALUE: 8,
|
|
30
|
+
HAS_NUMERIC_VALUE: 16,
|
|
31
|
+
HAS_POSITIVE_NUMERIC_VALUE: 32 | 16,
|
|
32
|
+
HAS_OVERLOADED_BOOLEAN_VALUE: 64,
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
35
|
* Inject some specialized knowledge about the DOM. This takes a config object
|
|
@@ -50,6 +48,9 @@ var DOMPropertyInjection = {
|
|
|
50
48
|
* attribute name. Attribute names not specified use the **lowercase**
|
|
51
49
|
* normalized name.
|
|
52
50
|
*
|
|
51
|
+
* DOMAttributeNamespaces: object mapping React attribute name to the DOM
|
|
52
|
+
* attribute namespace URL. (Attribute names not specified use no namespace.)
|
|
53
|
+
*
|
|
53
54
|
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
|
|
54
55
|
* Property names not specified use the normalized name.
|
|
55
56
|
*
|
|
@@ -58,27 +59,19 @@ var DOMPropertyInjection = {
|
|
|
58
59
|
*
|
|
59
60
|
* @param {object} domPropertyConfig the config as described above.
|
|
60
61
|
*/
|
|
61
|
-
injectDOMPropertyConfig: function(domPropertyConfig) {
|
|
62
|
+
injectDOMPropertyConfig: function (domPropertyConfig) {
|
|
62
63
|
var Properties = domPropertyConfig.Properties || {};
|
|
64
|
+
var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {};
|
|
63
65
|
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
|
|
64
66
|
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
|
|
65
67
|
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
|
|
66
68
|
|
|
67
69
|
if (domPropertyConfig.isCustomAttribute) {
|
|
68
|
-
DOMProperty._isCustomAttributeFunctions.push(
|
|
69
|
-
domPropertyConfig.isCustomAttribute
|
|
70
|
-
);
|
|
70
|
+
DOMProperty._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
for (var propName in Properties) {
|
|
74
|
-
|
|
75
|
-
!DOMProperty.isStandardName.hasOwnProperty(propName),
|
|
76
|
-
'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
|
|
77
|
-
'\'%s\' which has already been injected. You may be accidentally ' +
|
|
78
|
-
'injecting the same DOM property config twice, or you may be ' +
|
|
79
|
-
'injecting two configs that have conflicting property names.',
|
|
80
|
-
propName
|
|
81
|
-
) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
|
|
74
|
+
'production' !== process.env.NODE_ENV ? invariant(!DOMProperty.isStandardName.hasOwnProperty(propName), 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' + '\'%s\' which has already been injected. You may be accidentally ' + 'injecting the same DOM property config twice, or you may be ' + 'injecting two configs that have conflicting property names.', propName) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName));
|
|
82
75
|
|
|
83
76
|
DOMProperty.isStandardName[propName] = true;
|
|
84
77
|
|
|
@@ -93,10 +86,13 @@ var DOMPropertyInjection = {
|
|
|
93
86
|
DOMProperty.getAttributeName[propName] = lowerCased;
|
|
94
87
|
}
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
if (DOMAttributeNamespaces.hasOwnProperty(propName)) {
|
|
90
|
+
DOMProperty.getAttributeNamespace[propName] = DOMAttributeNamespaces[propName];
|
|
91
|
+
} else {
|
|
92
|
+
DOMProperty.getAttributeNamespace[propName] = null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
DOMProperty.getPropertyName[propName] = DOMPropertyNames.hasOwnProperty(propName) ? DOMPropertyNames[propName] : propName;
|
|
100
96
|
|
|
101
97
|
if (DOMMutationMethods.hasOwnProperty(propName)) {
|
|
102
98
|
DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
|
|
@@ -105,45 +101,17 @@ var DOMPropertyInjection = {
|
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
var propConfig = Properties[propName];
|
|
108
|
-
DOMProperty.mustUseAttribute[propName] =
|
|
109
|
-
|
|
110
|
-
DOMProperty.
|
|
111
|
-
|
|
112
|
-
DOMProperty.
|
|
113
|
-
|
|
114
|
-
DOMProperty.
|
|
115
|
-
|
|
116
|
-
DOMProperty.
|
|
117
|
-
|
|
118
|
-
DOMProperty.
|
|
119
|
-
checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
|
|
120
|
-
DOMProperty.hasOverloadedBooleanValue[propName] =
|
|
121
|
-
checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
|
|
122
|
-
|
|
123
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
124
|
-
!DOMProperty.mustUseAttribute[propName] ||
|
|
125
|
-
!DOMProperty.mustUseProperty[propName],
|
|
126
|
-
'DOMProperty: Cannot require using both attribute and property: %s',
|
|
127
|
-
propName
|
|
128
|
-
) : invariant(!DOMProperty.mustUseAttribute[propName] ||
|
|
129
|
-
!DOMProperty.mustUseProperty[propName]));
|
|
130
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
131
|
-
DOMProperty.mustUseProperty[propName] ||
|
|
132
|
-
!DOMProperty.hasSideEffects[propName],
|
|
133
|
-
'DOMProperty: Properties that have side effects must use property: %s',
|
|
134
|
-
propName
|
|
135
|
-
) : invariant(DOMProperty.mustUseProperty[propName] ||
|
|
136
|
-
!DOMProperty.hasSideEffects[propName]));
|
|
137
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
138
|
-
!!DOMProperty.hasBooleanValue[propName] +
|
|
139
|
-
!!DOMProperty.hasNumericValue[propName] +
|
|
140
|
-
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
|
|
141
|
-
'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
|
|
142
|
-
'numeric value, but not a combination: %s',
|
|
143
|
-
propName
|
|
144
|
-
) : invariant(!!DOMProperty.hasBooleanValue[propName] +
|
|
145
|
-
!!DOMProperty.hasNumericValue[propName] +
|
|
146
|
-
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
|
|
104
|
+
DOMProperty.mustUseAttribute[propName] = checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
|
|
105
|
+
DOMProperty.mustUseProperty[propName] = checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
|
|
106
|
+
DOMProperty.hasSideEffects[propName] = checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
|
|
107
|
+
DOMProperty.hasBooleanValue[propName] = checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
|
|
108
|
+
DOMProperty.hasNumericValue[propName] = checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
|
|
109
|
+
DOMProperty.hasPositiveNumericValue[propName] = checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
|
|
110
|
+
DOMProperty.hasOverloadedBooleanValue[propName] = checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
|
|
111
|
+
|
|
112
|
+
'production' !== process.env.NODE_ENV ? invariant(!DOMProperty.mustUseAttribute[propName] || !DOMProperty.mustUseProperty[propName], 'DOMProperty: Cannot require using both attribute and property: %s', propName) : invariant(!DOMProperty.mustUseAttribute[propName] || !DOMProperty.mustUseProperty[propName]);
|
|
113
|
+
'production' !== process.env.NODE_ENV ? invariant(DOMProperty.mustUseProperty[propName] || !DOMProperty.hasSideEffects[propName], 'DOMProperty: Properties that have side effects must use property: %s', propName) : invariant(DOMProperty.mustUseProperty[propName] || !DOMProperty.hasSideEffects[propName]);
|
|
114
|
+
'production' !== process.env.NODE_ENV ? invariant(!!DOMProperty.hasBooleanValue[propName] + !!DOMProperty.hasNumericValue[propName] + !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName) : invariant(!!DOMProperty.hasBooleanValue[propName] + !!DOMProperty.hasNumericValue[propName] + !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1);
|
|
147
115
|
}
|
|
148
116
|
}
|
|
149
117
|
};
|
|
@@ -186,6 +154,12 @@ var DOMProperty = {
|
|
|
186
154
|
*/
|
|
187
155
|
getAttributeName: {},
|
|
188
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Mapping from normalized names to namespaces.
|
|
159
|
+
* @type {Object}
|
|
160
|
+
*/
|
|
161
|
+
getAttributeNamespace: {},
|
|
162
|
+
|
|
189
163
|
/**
|
|
190
164
|
* Mapping from normalized names to properties on DOM node instances.
|
|
191
165
|
* (This includes properties that mutate due to external factors.)
|
|
@@ -258,7 +232,7 @@ var DOMProperty = {
|
|
|
258
232
|
* Checks whether a property name is a custom attribute.
|
|
259
233
|
* @method
|
|
260
234
|
*/
|
|
261
|
-
isCustomAttribute: function(attributeName) {
|
|
235
|
+
isCustomAttribute: function (attributeName) {
|
|
262
236
|
for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
|
|
263
237
|
var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
|
|
264
238
|
if (isCustomAttributeFn(attributeName)) {
|
|
@@ -276,7 +250,7 @@ var DOMProperty = {
|
|
|
276
250
|
* TODO: Is it better to grab all the possible properties when creating an
|
|
277
251
|
* element to avoid having to create the same element twice?
|
|
278
252
|
*/
|
|
279
|
-
getDefaultValueForProperty: function(nodeName, prop) {
|
|
253
|
+
getDefaultValueForProperty: function (nodeName, prop) {
|
|
280
254
|
var nodeDefaults = defaultValueCache[nodeName];
|
|
281
255
|
var testElement;
|
|
282
256
|
if (!nodeDefaults) {
|
|
@@ -292,4 +266,4 @@ var DOMProperty = {
|
|
|
292
266
|
injection: DOMPropertyInjection
|
|
293
267
|
};
|
|
294
268
|
|
|
295
|
-
module.exports = DOMProperty;
|
|
269
|
+
module.exports = DOMProperty;
|