react 0.14.0-beta1 → 0.14.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/addons.js +8 -3
- package/dist/react-with-addons.js +5048 -4095
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4555 -3729
- package/dist/react.min.js +6 -5
- package/lib/AutoFocusUtils.js +3 -3
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +18 -3
- package/lib/CSSPropertyOperations.js +27 -14
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +15 -14
- package/lib/DOMChildrenOperations.js +22 -7
- package/lib/DOMProperty.js +8 -8
- package/lib/DOMPropertyOperations.js +23 -10
- package/lib/Danger.js +21 -16
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +18 -10
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +29 -21
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +34 -38
- package/lib/EventPropagators.js +8 -8
- package/lib/FallbackCompositionState.js +9 -3
- package/lib/HTMLDOMPropertyConfig.js +24 -4
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +8 -8
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +3 -5
- package/lib/React.js +18 -7
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +36 -7
- package/lib/ReactCSSTransitionGroup.js +35 -9
- package/lib/ReactCSSTransitionGroupChild.js +48 -30
- package/lib/ReactChildReconciler.js +24 -19
- package/lib/ReactChildren.js +72 -32
- package/lib/ReactClass.js +46 -46
- package/lib/ReactComponent.js +18 -16
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +1 -1
- package/lib/ReactCompositeComponent.js +95 -44
- package/lib/ReactDOM.js +74 -159
- package/lib/ReactDOMComponent.js +235 -93
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
- package/lib/ReactDOMIDOperations.js +8 -81
- package/lib/ReactDOMInput.js +18 -9
- package/lib/ReactDOMOption.js +7 -7
- package/lib/ReactDOMSelect.js +9 -9
- package/lib/ReactDOMSelection.js +19 -3
- package/lib/ReactDOMServer.js +5 -3
- package/lib/ReactDOMTextComponent.js +33 -20
- package/lib/ReactDOMTextarea.js +14 -12
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +23 -25
- package/lib/ReactDefaultPerf.js +17 -11
- package/lib/ReactDefaultPerfAnalysis.js +13 -12
- package/lib/ReactElement.js +85 -39
- package/lib/ReactElementValidator.js +47 -90
- package/lib/ReactEmptyComponent.js +26 -62
- package/lib/ReactEmptyComponentRegistry.js +48 -0
- package/lib/ReactErrorUtils.js +53 -9
- package/lib/ReactEventEmitterMixin.js +2 -2
- package/lib/ReactEventListener.js +33 -21
- package/lib/ReactFragment.js +27 -118
- package/lib/ReactInjection.js +10 -12
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -11
- package/lib/ReactIsomorphic.js +15 -11
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +186 -85
- package/lib/ReactMultiChild.js +119 -25
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -3
- package/lib/ReactNoopUpdateQueue.js +3 -3
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +38 -9
- package/lib/ReactReconcileTransaction.js +10 -8
- package/lib/ReactReconciler.js +5 -6
- package/lib/ReactRef.js +14 -2
- package/lib/ReactServerBatchingStrategy.js +5 -5
- package/lib/ReactServerRendering.js +12 -12
- package/lib/ReactServerRenderingTransaction.js +6 -5
- package/lib/ReactTestUtils.js +47 -39
- package/lib/ReactTransitionChildMapping.js +3 -6
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +19 -19
- package/lib/ReactUpdates.js +15 -15
- package/lib/{performance.js → ReactVersion.js} +3 -12
- package/lib/ReactWithAddons.js +24 -15
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +19 -9
- package/lib/SimpleEventPlugin.js +198 -43
- package/lib/SyntheticClipboardEvent.js +1 -1
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +18 -4
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +1 -1
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +3 -3
- package/lib/SyntheticTouchEvent.js +2 -2
- package/lib/SyntheticUIEvent.js +2 -2
- package/lib/SyntheticWheelEvent.js +1 -1
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +7 -7
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +11 -6
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +7 -6
- package/lib/findDOMNode.js +9 -9
- package/lib/flattenChildren.js +4 -4
- package/lib/getEventKey.js +1 -1
- package/lib/{isTextNode.js → getTestDocument.js} +7 -11
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +15 -17
- package/lib/isEventSupported.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +216 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +1 -1
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +12 -8
- package/lib/sliceChildren.js +34 -0
- package/lib/traverseAllChildren.js +25 -18
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +6 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +1 -51
- package/dist/JSXTransformer.js +0 -17588
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/ReactDOMClient.js +0 -90
- package/lib/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -93
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/joinClasses.js +0 -39
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/memoizeStringOnly.js +0 -31
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -57
package/lib/ReactDOMComponent.js
CHANGED
|
@@ -14,31 +14,33 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
var AutoFocusUtils = require(
|
|
18
|
-
var CSSPropertyOperations = require(
|
|
19
|
-
var DOMProperty = require(
|
|
20
|
-
var DOMPropertyOperations = require(
|
|
21
|
-
var EventConstants = require(
|
|
22
|
-
var ReactBrowserEventEmitter = require(
|
|
23
|
-
var ReactComponentBrowserEnvironment = require(
|
|
24
|
-
var ReactDOMButton = require(
|
|
25
|
-
var ReactDOMInput = require(
|
|
26
|
-
var ReactDOMOption = require(
|
|
27
|
-
var ReactDOMSelect = require(
|
|
28
|
-
var ReactDOMTextarea = require(
|
|
29
|
-
var ReactMount = require(
|
|
30
|
-
var ReactMultiChild = require(
|
|
31
|
-
var ReactPerf = require(
|
|
32
|
-
var ReactUpdateQueue = require(
|
|
33
|
-
|
|
34
|
-
var assign = require(
|
|
35
|
-
var escapeTextContentForBrowser = require(
|
|
36
|
-
var invariant = require(
|
|
37
|
-
var isEventSupported = require(
|
|
38
|
-
var keyOf = require(
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
17
|
+
var AutoFocusUtils = require('./AutoFocusUtils');
|
|
18
|
+
var CSSPropertyOperations = require('./CSSPropertyOperations');
|
|
19
|
+
var DOMProperty = require('./DOMProperty');
|
|
20
|
+
var DOMPropertyOperations = require('./DOMPropertyOperations');
|
|
21
|
+
var EventConstants = require('./EventConstants');
|
|
22
|
+
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
23
|
+
var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
|
|
24
|
+
var ReactDOMButton = require('./ReactDOMButton');
|
|
25
|
+
var ReactDOMInput = require('./ReactDOMInput');
|
|
26
|
+
var ReactDOMOption = require('./ReactDOMOption');
|
|
27
|
+
var ReactDOMSelect = require('./ReactDOMSelect');
|
|
28
|
+
var ReactDOMTextarea = require('./ReactDOMTextarea');
|
|
29
|
+
var ReactMount = require('./ReactMount');
|
|
30
|
+
var ReactMultiChild = require('./ReactMultiChild');
|
|
31
|
+
var ReactPerf = require('./ReactPerf');
|
|
32
|
+
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
33
|
+
|
|
34
|
+
var assign = require('./Object.assign');
|
|
35
|
+
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
|
|
36
|
+
var invariant = require('fbjs/lib/invariant');
|
|
37
|
+
var isEventSupported = require('./isEventSupported');
|
|
38
|
+
var keyOf = require('fbjs/lib/keyOf');
|
|
39
|
+
var setInnerHTML = require('./setInnerHTML');
|
|
40
|
+
var setTextContent = require('./setTextContent');
|
|
41
|
+
var shallowEqual = require('fbjs/lib/shallowEqual');
|
|
42
|
+
var validateDOMNesting = require('./validateDOMNesting');
|
|
43
|
+
var warning = require('fbjs/lib/warning');
|
|
42
44
|
|
|
43
45
|
var deleteListener = ReactBrowserEventEmitter.deleteListener;
|
|
44
46
|
var listenTo = ReactBrowserEventEmitter.listenTo;
|
|
@@ -71,13 +73,13 @@ function getDeclarationErrorAddendum(internalInstance) {
|
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
var legacyPropsDescriptor;
|
|
74
|
-
if (
|
|
76
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
75
77
|
legacyPropsDescriptor = {
|
|
76
78
|
props: {
|
|
77
79
|
enumerable: false,
|
|
78
80
|
get: function () {
|
|
79
81
|
var component = this._reactInternalComponent;
|
|
80
|
-
|
|
82
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .props of a DOM node; instead, ' + 'recreate the props as `render` did originally or read the DOM ' + 'properties/attributes directly from this node (e.g., ' + 'this.refs.box.className).%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
81
83
|
return component._currentElement.props;
|
|
82
84
|
}
|
|
83
85
|
}
|
|
@@ -85,32 +87,32 @@ if ('production' !== process.env.NODE_ENV) {
|
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
function legacyGetDOMNode() {
|
|
88
|
-
if (
|
|
90
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
89
91
|
var component = this._reactInternalComponent;
|
|
90
|
-
|
|
92
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .getDOMNode() of a DOM node; ' + 'instead, use the node directly.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
91
93
|
}
|
|
92
94
|
return this;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
function legacyIsMounted() {
|
|
96
98
|
var component = this._reactInternalComponent;
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
100
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .isMounted() of a DOM node.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
99
101
|
}
|
|
100
102
|
return !!component;
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
function legacySetStateEtc() {
|
|
104
|
-
if (
|
|
106
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
105
107
|
var component = this._reactInternalComponent;
|
|
106
|
-
|
|
108
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setState(), .replaceState(), or ' + '.forceUpdate() of a DOM node. This is a no-op.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
function legacySetProps(partialProps, callback) {
|
|
111
113
|
var component = this._reactInternalComponent;
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
115
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
114
116
|
}
|
|
115
117
|
if (!component) {
|
|
116
118
|
return;
|
|
@@ -123,8 +125,8 @@ function legacySetProps(partialProps, callback) {
|
|
|
123
125
|
|
|
124
126
|
function legacyReplaceProps(partialProps, callback) {
|
|
125
127
|
var component = this._reactInternalComponent;
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
129
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .replaceProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined;
|
|
128
130
|
}
|
|
129
131
|
if (!component) {
|
|
130
132
|
return;
|
|
@@ -135,6 +137,30 @@ function legacyReplaceProps(partialProps, callback) {
|
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
|
|
140
|
+
function friendlyStringify(obj) {
|
|
141
|
+
if (typeof obj === 'object') {
|
|
142
|
+
if (Array.isArray(obj)) {
|
|
143
|
+
return '[' + obj.map(friendlyStringify).join(', ') + ']';
|
|
144
|
+
} else {
|
|
145
|
+
var pairs = [];
|
|
146
|
+
for (var key in obj) {
|
|
147
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
148
|
+
var keyEscaped = /^[a-z$_][\w$_]*$/i.test(key) ? key : JSON.stringify(key);
|
|
149
|
+
pairs.push(keyEscaped + ': ' + friendlyStringify(obj[key]));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return '{' + pairs.join(', ') + '}';
|
|
153
|
+
}
|
|
154
|
+
} else if (typeof obj === 'string') {
|
|
155
|
+
return JSON.stringify(obj);
|
|
156
|
+
} else if (typeof obj === 'function') {
|
|
157
|
+
return '[function object]';
|
|
158
|
+
}
|
|
159
|
+
// Differs from JSON.stringify in that undefined becauses undefined and that
|
|
160
|
+
// inf and nan don't become null
|
|
161
|
+
return String(obj);
|
|
162
|
+
}
|
|
163
|
+
|
|
138
164
|
var styleMutationWarning = {};
|
|
139
165
|
|
|
140
166
|
function checkAndWarnForMutatedStyle(style1, style2, component) {
|
|
@@ -160,14 +186,9 @@ function checkAndWarnForMutatedStyle(style1, style2, component) {
|
|
|
160
186
|
|
|
161
187
|
styleMutationWarning[hash] = true;
|
|
162
188
|
|
|
163
|
-
|
|
189
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '`%s` was passed a style object that has previously been mutated. ' + 'Mutating `style` is deprecated. Consider cloning it beforehand. Check ' + 'the `render` %s. Previous style: %s. Mutated style: %s.', componentName, owner ? 'of `' + ownerName + '`' : 'using <' + componentName + '>', friendlyStringify(style1), friendlyStringify(style2)) : undefined;
|
|
164
190
|
}
|
|
165
191
|
|
|
166
|
-
/**
|
|
167
|
-
* Optionally injectable operations for mutating the DOM
|
|
168
|
-
*/
|
|
169
|
-
var BackendIDOperations = null;
|
|
170
|
-
|
|
171
192
|
/**
|
|
172
193
|
* @param {object} component
|
|
173
194
|
* @param {?object} props
|
|
@@ -177,27 +198,27 @@ function assertValidProps(component, props) {
|
|
|
177
198
|
return;
|
|
178
199
|
}
|
|
179
200
|
// Note the use of `==` which checks for null or undefined.
|
|
180
|
-
if (
|
|
201
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
181
202
|
if (voidElementTags[component._tag]) {
|
|
182
|
-
|
|
203
|
+
process.env.NODE_ENV !== 'production' ? warning(props.children == null && props.dangerouslySetInnerHTML == null, '%s is a void element tag and must not have `children` or ' + 'use `props.dangerouslySetInnerHTML`.%s', component._tag, component._currentElement._owner ? ' Check the render method of ' + component._currentElement._owner.getName() + '.' : '') : undefined;
|
|
183
204
|
}
|
|
184
205
|
}
|
|
185
206
|
if (props.dangerouslySetInnerHTML != null) {
|
|
186
|
-
!(props.children == null) ?
|
|
187
|
-
!(typeof props.dangerouslySetInnerHTML === 'object' && '__html' in props.dangerouslySetInnerHTML) ?
|
|
207
|
+
!(props.children == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : invariant(false) : undefined;
|
|
208
|
+
!(typeof props.dangerouslySetInnerHTML === 'object' && '__html' in props.dangerouslySetInnerHTML) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' + 'for more information.') : invariant(false) : undefined;
|
|
188
209
|
}
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
210
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
211
|
+
process.env.NODE_ENV !== 'production' ? warning(props.innerHTML == null, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.') : undefined;
|
|
212
|
+
process.env.NODE_ENV !== 'production' ? warning(!props.contentEditable || props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.') : undefined;
|
|
192
213
|
}
|
|
193
|
-
!(props.style == null || typeof props.style === 'object') ?
|
|
214
|
+
!(props.style == null || typeof props.style === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + 'using JSX.%s', getDeclarationErrorAddendum(component)) : invariant(false) : undefined;
|
|
194
215
|
}
|
|
195
216
|
|
|
196
217
|
function enqueuePutListener(id, registrationName, listener, transaction) {
|
|
197
|
-
if (
|
|
218
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
198
219
|
// IE8 has no API for event capturing and the `onScroll` event doesn't
|
|
199
220
|
// bubble.
|
|
200
|
-
|
|
221
|
+
process.env.NODE_ENV !== 'production' ? warning(registrationName !== 'onScroll' || isEventSupported('scroll', true), 'This browser doesn\'t support the `onScroll` event') : undefined;
|
|
201
222
|
}
|
|
202
223
|
var container = ReactMount.findReactContainerForID(id);
|
|
203
224
|
if (container) {
|
|
@@ -216,17 +237,57 @@ function putListener() {
|
|
|
216
237
|
ReactBrowserEventEmitter.putListener(listenerToPut.id, listenerToPut.registrationName, listenerToPut.listener);
|
|
217
238
|
}
|
|
218
239
|
|
|
240
|
+
// There are so many media events, it makes sense to just
|
|
241
|
+
// maintain a list rather than create a `trapBubbledEvent` for each
|
|
242
|
+
var mediaEvents = {
|
|
243
|
+
topAbort: 'abort',
|
|
244
|
+
topCanPlay: 'canplay',
|
|
245
|
+
topCanPlayThrough: 'canplaythrough',
|
|
246
|
+
topDurationChange: 'durationchange',
|
|
247
|
+
topEmptied: 'emptied',
|
|
248
|
+
topEncrypted: 'encrypted',
|
|
249
|
+
topEnded: 'ended',
|
|
250
|
+
topError: 'error',
|
|
251
|
+
topLoadedData: 'loadeddata',
|
|
252
|
+
topLoadedMetadata: 'loadedmetadata',
|
|
253
|
+
topLoadStart: 'loadstart',
|
|
254
|
+
topPause: 'pause',
|
|
255
|
+
topPlay: 'play',
|
|
256
|
+
topPlaying: 'playing',
|
|
257
|
+
topProgress: 'progress',
|
|
258
|
+
topRateChange: 'ratechange',
|
|
259
|
+
topSeeked: 'seeked',
|
|
260
|
+
topSeeking: 'seeking',
|
|
261
|
+
topStalled: 'stalled',
|
|
262
|
+
topSuspend: 'suspend',
|
|
263
|
+
topTimeUpdate: 'timeupdate',
|
|
264
|
+
topVolumeChange: 'volumechange',
|
|
265
|
+
topWaiting: 'waiting'
|
|
266
|
+
};
|
|
267
|
+
|
|
219
268
|
function trapBubbledEventsLocal() {
|
|
220
269
|
var inst = this;
|
|
221
270
|
// If a component renders to null or if another component fatals and causes
|
|
222
271
|
// the state of the tree to be corrupted, `node` here can be null.
|
|
223
|
-
!inst._rootNodeID ?
|
|
272
|
+
!inst._rootNodeID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Must be mounted to trap events') : invariant(false) : undefined;
|
|
224
273
|
var node = ReactMount.getNode(inst._rootNodeID);
|
|
225
|
-
!node ?
|
|
274
|
+
!node ? process.env.NODE_ENV !== 'production' ? invariant(false, 'trapBubbledEvent(...): Requires node to be rendered.') : invariant(false) : undefined;
|
|
226
275
|
|
|
227
276
|
switch (inst._tag) {
|
|
228
277
|
case 'iframe':
|
|
229
278
|
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
|
|
279
|
+
break;
|
|
280
|
+
case 'video':
|
|
281
|
+
case 'audio':
|
|
282
|
+
|
|
283
|
+
inst._wrapperState.listeners = [];
|
|
284
|
+
// create listener for each media event
|
|
285
|
+
for (var event in mediaEvents) {
|
|
286
|
+
if (mediaEvents.hasOwnProperty(event)) {
|
|
287
|
+
inst._wrapperState.listeners.push(ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes[event], mediaEvents[event], node));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
230
291
|
break;
|
|
231
292
|
case 'img':
|
|
232
293
|
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
|
|
@@ -237,6 +298,10 @@ function trapBubbledEventsLocal() {
|
|
|
237
298
|
}
|
|
238
299
|
}
|
|
239
300
|
|
|
301
|
+
function mountReadyInputWrapper() {
|
|
302
|
+
ReactDOMInput.mountReadyWrapper(this);
|
|
303
|
+
}
|
|
304
|
+
|
|
240
305
|
function postUpdateSelectWrapper() {
|
|
241
306
|
ReactDOMSelect.postUpdateWrapper(this);
|
|
242
307
|
}
|
|
@@ -262,6 +327,7 @@ var omittedCloseTags = {
|
|
|
262
327
|
'wbr': true
|
|
263
328
|
};
|
|
264
329
|
|
|
330
|
+
// NOTE: menuitem's close tag should be omitted, but that causes problems.
|
|
265
331
|
var newlineEatingTags = {
|
|
266
332
|
'listing': true,
|
|
267
333
|
'pre': true,
|
|
@@ -285,18 +351,16 @@ var hasOwnProperty = ({}).hasOwnProperty;
|
|
|
285
351
|
|
|
286
352
|
function validateDangerousTag(tag) {
|
|
287
353
|
if (!hasOwnProperty.call(validatedTagCache, tag)) {
|
|
288
|
-
!VALID_TAG_REGEX.test(tag) ?
|
|
354
|
+
!VALID_TAG_REGEX.test(tag) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Invalid tag: %s', tag) : invariant(false) : undefined;
|
|
289
355
|
validatedTagCache[tag] = true;
|
|
290
356
|
}
|
|
291
357
|
}
|
|
292
358
|
|
|
293
|
-
function
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(info, inst._tag, inst);
|
|
299
|
-
}
|
|
359
|
+
function processChildContextDev(context, inst) {
|
|
360
|
+
// Pass down our tag name to child components for validation purposes
|
|
361
|
+
context = assign({}, context);
|
|
362
|
+
var info = context[validateDOMNesting.ancestorInfoContextKey];
|
|
363
|
+
context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(info, inst._tag, inst);
|
|
300
364
|
return context;
|
|
301
365
|
}
|
|
302
366
|
|
|
@@ -328,6 +392,10 @@ function ReactDOMComponent(tag) {
|
|
|
328
392
|
this._wrapperState = null;
|
|
329
393
|
this._topLevelWrapper = null;
|
|
330
394
|
this._nodeWithLegacyProperties = null;
|
|
395
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
396
|
+
this._unprocessedContextDev = null;
|
|
397
|
+
this._processedContextDev = null;
|
|
398
|
+
}
|
|
331
399
|
}
|
|
332
400
|
|
|
333
401
|
ReactDOMComponent.displayName = 'ReactDOMComponent';
|
|
@@ -357,6 +425,8 @@ ReactDOMComponent.Mixin = {
|
|
|
357
425
|
case 'iframe':
|
|
358
426
|
case 'img':
|
|
359
427
|
case 'form':
|
|
428
|
+
case 'video':
|
|
429
|
+
case 'audio':
|
|
360
430
|
this._wrapperState = {
|
|
361
431
|
listeners: null
|
|
362
432
|
};
|
|
@@ -385,18 +455,43 @@ ReactDOMComponent.Mixin = {
|
|
|
385
455
|
}
|
|
386
456
|
|
|
387
457
|
assertValidProps(this, props);
|
|
388
|
-
if (
|
|
458
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
389
459
|
if (context[validateDOMNesting.ancestorInfoContextKey]) {
|
|
390
460
|
validateDOMNesting(this._tag, this, context[validateDOMNesting.ancestorInfoContextKey]);
|
|
391
461
|
}
|
|
392
462
|
}
|
|
393
463
|
|
|
394
|
-
|
|
395
|
-
|
|
464
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
465
|
+
this._unprocessedContextDev = context;
|
|
466
|
+
this._processedContextDev = processChildContextDev(context, this);
|
|
467
|
+
context = this._processedContextDev;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
var mountImage;
|
|
471
|
+
if (transaction.useCreateElement) {
|
|
472
|
+
var ownerDocument = context[ReactMount.ownerDocumentContextKey];
|
|
473
|
+
var el = ownerDocument.createElement(this._currentElement.type);
|
|
474
|
+
DOMPropertyOperations.setAttributeForID(el, this._rootNodeID);
|
|
475
|
+
// Populate node cache
|
|
476
|
+
ReactMount.getID(el);
|
|
477
|
+
this._updateDOMProperties({}, props, transaction, el);
|
|
478
|
+
this._createInitialChildren(transaction, props, context, el);
|
|
479
|
+
mountImage = el;
|
|
480
|
+
} else {
|
|
481
|
+
var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props);
|
|
482
|
+
var tagContent = this._createContentMarkup(transaction, props, context);
|
|
483
|
+
if (!tagContent && omittedCloseTags[this._tag]) {
|
|
484
|
+
mountImage = tagOpen + '/>';
|
|
485
|
+
} else {
|
|
486
|
+
mountImage = tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
|
|
487
|
+
}
|
|
488
|
+
}
|
|
396
489
|
|
|
397
490
|
switch (this._tag) {
|
|
398
|
-
case 'button':
|
|
399
491
|
case 'input':
|
|
492
|
+
transaction.getReactMountReady().enqueue(mountReadyInputWrapper, this);
|
|
493
|
+
// falls through
|
|
494
|
+
case 'button':
|
|
400
495
|
case 'select':
|
|
401
496
|
case 'textarea':
|
|
402
497
|
if (props.autoFocus) {
|
|
@@ -405,10 +500,7 @@ ReactDOMComponent.Mixin = {
|
|
|
405
500
|
break;
|
|
406
501
|
}
|
|
407
502
|
|
|
408
|
-
|
|
409
|
-
return tagOpen + '/>';
|
|
410
|
-
}
|
|
411
|
-
return tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
|
|
503
|
+
return mountImage;
|
|
412
504
|
},
|
|
413
505
|
|
|
414
506
|
/**
|
|
@@ -436,11 +528,13 @@ ReactDOMComponent.Mixin = {
|
|
|
436
528
|
continue;
|
|
437
529
|
}
|
|
438
530
|
if (registrationNameModules.hasOwnProperty(propKey)) {
|
|
439
|
-
|
|
531
|
+
if (propValue) {
|
|
532
|
+
enqueuePutListener(this._rootNodeID, propKey, propValue, transaction);
|
|
533
|
+
}
|
|
440
534
|
} else {
|
|
441
535
|
if (propKey === STYLE) {
|
|
442
536
|
if (propValue) {
|
|
443
|
-
if (
|
|
537
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
444
538
|
// See `_updateDOMProperties`. style block
|
|
445
539
|
this._previousStyle = propValue;
|
|
446
540
|
}
|
|
@@ -495,7 +589,7 @@ ReactDOMComponent.Mixin = {
|
|
|
495
589
|
// TODO: Validate that text is allowed as a child of this node
|
|
496
590
|
ret = escapeTextContentForBrowser(contentToUse);
|
|
497
591
|
} else if (childrenToUse != null) {
|
|
498
|
-
var mountImages = this.mountChildren(childrenToUse, transaction,
|
|
592
|
+
var mountImages = this.mountChildren(childrenToUse, transaction, context);
|
|
499
593
|
ret = mountImages.join('');
|
|
500
594
|
}
|
|
501
595
|
}
|
|
@@ -516,6 +610,28 @@ ReactDOMComponent.Mixin = {
|
|
|
516
610
|
}
|
|
517
611
|
},
|
|
518
612
|
|
|
613
|
+
_createInitialChildren: function (transaction, props, context, el) {
|
|
614
|
+
// Intentional use of != to avoid catching zero/false.
|
|
615
|
+
var innerHTML = props.dangerouslySetInnerHTML;
|
|
616
|
+
if (innerHTML != null) {
|
|
617
|
+
if (innerHTML.__html != null) {
|
|
618
|
+
setInnerHTML(el, innerHTML.__html);
|
|
619
|
+
}
|
|
620
|
+
} else {
|
|
621
|
+
var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null;
|
|
622
|
+
var childrenToUse = contentToUse != null ? null : props.children;
|
|
623
|
+
if (contentToUse != null) {
|
|
624
|
+
// TODO: Validate that text is allowed as a child of this node
|
|
625
|
+
setTextContent(el, contentToUse);
|
|
626
|
+
} else if (childrenToUse != null) {
|
|
627
|
+
var mountImages = this.mountChildren(childrenToUse, transaction, context);
|
|
628
|
+
for (var i = 0; i < mountImages.length; i++) {
|
|
629
|
+
el.appendChild(mountImages[i]);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
|
|
519
635
|
/**
|
|
520
636
|
* Receives a next element and updates the component.
|
|
521
637
|
*
|
|
@@ -569,9 +685,20 @@ ReactDOMComponent.Mixin = {
|
|
|
569
685
|
break;
|
|
570
686
|
}
|
|
571
687
|
|
|
688
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
689
|
+
// If the context is reference-equal to the old one, pass down the same
|
|
690
|
+
// processed object so the update bailout in ReactReconciler behaves
|
|
691
|
+
// correctly (and identically in dev and prod). See #5005.
|
|
692
|
+
if (this._unprocessedContextDev !== context) {
|
|
693
|
+
this._unprocessedContextDev = context;
|
|
694
|
+
this._processedContextDev = processChildContextDev(context, this);
|
|
695
|
+
}
|
|
696
|
+
context = this._processedContextDev;
|
|
697
|
+
}
|
|
698
|
+
|
|
572
699
|
assertValidProps(this, nextProps);
|
|
573
|
-
this._updateDOMProperties(lastProps, nextProps, transaction);
|
|
574
|
-
this._updateDOMChildren(lastProps, nextProps, transaction,
|
|
700
|
+
this._updateDOMProperties(lastProps, nextProps, transaction, null);
|
|
701
|
+
this._updateDOMChildren(lastProps, nextProps, transaction, context);
|
|
575
702
|
|
|
576
703
|
if (!canDefineProperty && this._nodeWithLegacyProperties) {
|
|
577
704
|
this._nodeWithLegacyProperties.props = nextProps;
|
|
@@ -599,8 +726,9 @@ ReactDOMComponent.Mixin = {
|
|
|
599
726
|
* @param {object} lastProps
|
|
600
727
|
* @param {object} nextProps
|
|
601
728
|
* @param {ReactReconcileTransaction} transaction
|
|
729
|
+
* @param {?DOMElement} node
|
|
602
730
|
*/
|
|
603
|
-
_updateDOMProperties: function (lastProps, nextProps, transaction) {
|
|
731
|
+
_updateDOMProperties: function (lastProps, nextProps, transaction, node) {
|
|
604
732
|
var propKey;
|
|
605
733
|
var styleName;
|
|
606
734
|
var styleUpdates;
|
|
@@ -625,7 +753,10 @@ ReactDOMComponent.Mixin = {
|
|
|
625
753
|
deleteListener(this._rootNodeID, propKey);
|
|
626
754
|
}
|
|
627
755
|
} else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
|
|
628
|
-
|
|
756
|
+
if (!node) {
|
|
757
|
+
node = ReactMount.getNode(this._rootNodeID);
|
|
758
|
+
}
|
|
759
|
+
DOMPropertyOperations.deleteValueForProperty(node, propKey);
|
|
629
760
|
}
|
|
630
761
|
}
|
|
631
762
|
for (propKey in nextProps) {
|
|
@@ -636,7 +767,7 @@ ReactDOMComponent.Mixin = {
|
|
|
636
767
|
}
|
|
637
768
|
if (propKey === STYLE) {
|
|
638
769
|
if (nextProp) {
|
|
639
|
-
if (
|
|
770
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
640
771
|
checkAndWarnForMutatedStyle(this._previousStyleCopy, this._previousStyle, this);
|
|
641
772
|
this._previousStyle = nextProp;
|
|
642
773
|
}
|
|
@@ -670,13 +801,29 @@ ReactDOMComponent.Mixin = {
|
|
|
670
801
|
deleteListener(this._rootNodeID, propKey);
|
|
671
802
|
}
|
|
672
803
|
} else if (isCustomComponent(this._tag, nextProps)) {
|
|
673
|
-
|
|
804
|
+
if (!node) {
|
|
805
|
+
node = ReactMount.getNode(this._rootNodeID);
|
|
806
|
+
}
|
|
807
|
+
DOMPropertyOperations.setValueForAttribute(node, propKey, nextProp);
|
|
674
808
|
} else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
|
|
675
|
-
|
|
809
|
+
if (!node) {
|
|
810
|
+
node = ReactMount.getNode(this._rootNodeID);
|
|
811
|
+
}
|
|
812
|
+
// If we're updating to null or undefined, we should remove the property
|
|
813
|
+
// from the DOM node instead of inadvertantly setting to a string. This
|
|
814
|
+
// brings us in line with the same behavior we have on initial render.
|
|
815
|
+
if (nextProp != null) {
|
|
816
|
+
DOMPropertyOperations.setValueForProperty(node, propKey, nextProp);
|
|
817
|
+
} else {
|
|
818
|
+
DOMPropertyOperations.deleteValueForProperty(node, propKey);
|
|
819
|
+
}
|
|
676
820
|
}
|
|
677
821
|
}
|
|
678
822
|
if (styleUpdates) {
|
|
679
|
-
|
|
823
|
+
if (!node) {
|
|
824
|
+
node = ReactMount.getNode(this._rootNodeID);
|
|
825
|
+
}
|
|
826
|
+
CSSPropertyOperations.setValueForStyles(node, styleUpdates);
|
|
680
827
|
}
|
|
681
828
|
},
|
|
682
829
|
|
|
@@ -716,7 +863,7 @@ ReactDOMComponent.Mixin = {
|
|
|
716
863
|
}
|
|
717
864
|
} else if (nextHtml != null) {
|
|
718
865
|
if (lastHtml !== nextHtml) {
|
|
719
|
-
|
|
866
|
+
this.updateMarkup('' + nextHtml);
|
|
720
867
|
}
|
|
721
868
|
} else if (nextChildren != null) {
|
|
722
869
|
this.updateChildren(nextChildren, transaction, context);
|
|
@@ -734,6 +881,8 @@ ReactDOMComponent.Mixin = {
|
|
|
734
881
|
case 'iframe':
|
|
735
882
|
case 'img':
|
|
736
883
|
case 'form':
|
|
884
|
+
case 'video':
|
|
885
|
+
case 'audio':
|
|
737
886
|
var listeners = this._wrapperState.listeners;
|
|
738
887
|
if (listeners) {
|
|
739
888
|
for (var i = 0; i < listeners.length; i++) {
|
|
@@ -753,7 +902,7 @@ ReactDOMComponent.Mixin = {
|
|
|
753
902
|
* take advantage of React's reconciliation for styling and <title>
|
|
754
903
|
* management. So we just document it and throw in dangerous cases.
|
|
755
904
|
*/
|
|
756
|
-
!false ?
|
|
905
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, '<%s> tried to unmount. Because of cross-browser quirks it is ' + 'impossible to unmount some top-level components (eg <html>, ' + '<head>, and <body>) reliably and efficiently. To fix this, have a ' + 'single top-level component that never unmounts render these ' + 'elements.', this._tag) : invariant(false) : undefined;
|
|
757
906
|
break;
|
|
758
907
|
}
|
|
759
908
|
|
|
@@ -782,7 +931,7 @@ ReactDOMComponent.Mixin = {
|
|
|
782
931
|
node.setProps = legacySetProps;
|
|
783
932
|
node.replaceProps = legacyReplaceProps;
|
|
784
933
|
|
|
785
|
-
if (
|
|
934
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
786
935
|
if (canDefineProperty) {
|
|
787
936
|
Object.defineProperties(node, legacyPropsDescriptor);
|
|
788
937
|
} else {
|
|
@@ -808,11 +957,4 @@ ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', {
|
|
|
808
957
|
|
|
809
958
|
assign(ReactDOMComponent.prototype, ReactDOMComponent.Mixin, ReactMultiChild.Mixin);
|
|
810
959
|
|
|
811
|
-
|
|
812
|
-
injectIDOperations: function (IDOperations) {
|
|
813
|
-
ReactDOMComponent.BackendIDOperations = BackendIDOperations = IDOperations;
|
|
814
|
-
}
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
module.exports = ReactDOMComponent;
|
|
818
|
-
// NOTE: menuitem's close tag should be omitted, but that causes problems.
|
|
960
|
+
module.exports = ReactDOMComponent;
|