react 0.14.0-alpha2 → 0.14.0-beta3
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 +5 -2
- package/addons.js +6 -3
- package/dist/JSXTransformer.js +634 -274
- package/dist/react-with-addons.js +5350 -4954
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4777 -4408
- package/dist/react.min.js +6 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +3 -0
- package/lib/CSSPropertyOperations.js +13 -13
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +16 -14
- package/lib/DOMChildrenOperations.js +10 -6
- package/lib/DOMProperty.js +82 -117
- package/lib/DOMPropertyOperations.js +78 -33
- package/lib/Danger.js +14 -14
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +8 -8
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +13 -13
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +17 -17
- package/lib/EventPropagators.js +7 -7
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +13 -3
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +50 -38
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +14 -2
- package/lib/React.js +6 -6
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +16 -5
- package/lib/ReactCSSTransitionGroupChild.js +20 -11
- package/lib/ReactChildReconciler.js +25 -18
- package/lib/ReactChildren.js +9 -9
- package/lib/ReactClass.js +65 -83
- package/lib/ReactComponent.js +22 -17
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +80 -111
- package/lib/ReactDOM.js +72 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +378 -56
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/ReactDOMIDOperations.js +23 -23
- package/lib/ReactDOMInput.js +83 -99
- package/lib/ReactDOMOption.js +25 -45
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +2 -2
- package/lib/ReactDOMTextComponent.js +11 -11
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +24 -71
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -9
- package/lib/ReactElement.js +22 -83
- package/lib/ReactElementValidator.js +48 -117
- package/lib/ReactEmptyComponent.js +4 -4
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +57 -12
- package/lib/ReactFragment.js +22 -17
- package/lib/ReactInjection.js +11 -11
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +11 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +88 -88
- package/lib/ReactMultiChild.js +83 -22
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -8
- package/lib/ReactNoopUpdateQueue.js +118 -0
- 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 +49 -11
- package/lib/ReactReconcileTransaction.js +8 -8
- package/lib/ReactReconciler.js +18 -20
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +7 -7
- package/lib/ReactTestUtils.js +80 -58
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +61 -36
- package/lib/ReactUpdates.js +14 -17
- package/lib/ReactWithAddons.js +14 -16
- 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 +14 -15
- package/lib/SimpleEventPlugin.js +205 -29
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +9 -8
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +3 -3
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +5 -5
- package/lib/SyntheticTouchEvent.js +4 -4
- package/lib/SyntheticUIEvent.js +4 -4
- package/lib/SyntheticWheelEvent.js +3 -3
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +16 -10
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +47 -0
- package/lib/findDOMNode.js +11 -12
- package/lib/flattenChildren.js +4 -4
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +24 -20
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +210 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +2 -2
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/sliceChildren.js +51 -0
- package/lib/traverseAllChildren.js +15 -14
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +14 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +53 -1
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- package/lib/ReactDOMClient.js +0 -85
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- 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/createFullPageComponent.js +0 -51
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/emptyObject.js +0 -20
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -115
- 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/isTextNode.js +0 -25
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/performance.js +0 -23
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -61
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var invariant = require(
|
|
15
|
+
var invariant = require('fbjs/lib/invariant');
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Injectable ordering of event plugins.
|
|
@@ -37,15 +37,15 @@ function recomputePluginOrdering() {
|
|
|
37
37
|
for (var pluginName in namesToPlugins) {
|
|
38
38
|
var PluginModule = namesToPlugins[pluginName];
|
|
39
39
|
var pluginIndex = EventPluginOrder.indexOf(pluginName);
|
|
40
|
-
|
|
40
|
+
!(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) : undefined;
|
|
41
41
|
if (EventPluginRegistry.plugins[pluginIndex]) {
|
|
42
42
|
continue;
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
!PluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) : undefined;
|
|
45
45
|
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
|
|
46
46
|
var publishedEvents = PluginModule.eventTypes;
|
|
47
47
|
for (var eventName in publishedEvents) {
|
|
48
|
-
|
|
48
|
+
!publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) : undefined;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -59,7 +59,7 @@ function recomputePluginOrdering() {
|
|
|
59
59
|
* @private
|
|
60
60
|
*/
|
|
61
61
|
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
|
62
|
-
|
|
62
|
+
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) : undefined;
|
|
63
63
|
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
|
|
64
64
|
|
|
65
65
|
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
|
|
@@ -87,7 +87,7 @@ function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
|
|
87
87
|
* @private
|
|
88
88
|
*/
|
|
89
89
|
function publishRegistrationName(registrationName, PluginModule, eventName) {
|
|
90
|
-
|
|
90
|
+
!!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : undefined;
|
|
91
91
|
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
|
|
92
92
|
EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
|
|
93
93
|
}
|
|
@@ -129,7 +129,7 @@ var EventPluginRegistry = {
|
|
|
129
129
|
* @see {EventPluginHub.injection.injectEventPluginOrder}
|
|
130
130
|
*/
|
|
131
131
|
injectEventPluginOrder: function (InjectedEventPluginOrder) {
|
|
132
|
-
|
|
132
|
+
!!EventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.') : invariant(false) : undefined;
|
|
133
133
|
// Clone the ordering so it cannot be dynamically mutated.
|
|
134
134
|
EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
|
|
135
135
|
recomputePluginOrdering();
|
|
@@ -153,7 +153,7 @@ var EventPluginRegistry = {
|
|
|
153
153
|
}
|
|
154
154
|
var PluginModule = injectedNamesToPlugins[pluginName];
|
|
155
155
|
if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) {
|
|
156
|
-
|
|
156
|
+
!!namesToPlugins[pluginName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName) : invariant(false) : undefined;
|
|
157
157
|
namesToPlugins[pluginName] = PluginModule;
|
|
158
158
|
isOrderingDirty = true;
|
|
159
159
|
}
|
package/lib/EventPluginUtils.js
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var EventConstants = require(
|
|
14
|
+
var EventConstants = require('./EventConstants');
|
|
15
15
|
|
|
16
|
-
var invariant = require(
|
|
17
|
-
var warning = require(
|
|
16
|
+
var invariant = require('fbjs/lib/invariant');
|
|
17
|
+
var warning = require('fbjs/lib/warning');
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Injected dependencies:
|
|
@@ -28,8 +28,8 @@ var injection = {
|
|
|
28
28
|
Mount: null,
|
|
29
29
|
injectMount: function (InjectedMount) {
|
|
30
30
|
injection.Mount = InjectedMount;
|
|
31
|
-
if (
|
|
32
|
-
|
|
31
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
32
|
+
process.env.NODE_ENV !== 'production' ? warning(InjectedMount && InjectedMount.getNode && InjectedMount.getID, 'EventPluginUtils.injection.injectMount(...): Injected Mount ' + 'module is missing getNode or getID.') : undefined;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
};
|
|
@@ -48,7 +48,7 @@ function isStartish(topLevelType) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
var validateEventDispatches;
|
|
51
|
-
if (
|
|
51
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
52
52
|
validateEventDispatches = function (event) {
|
|
53
53
|
var dispatchListeners = event._dispatchListeners;
|
|
54
54
|
var dispatchIDs = event._dispatchIDs;
|
|
@@ -58,7 +58,7 @@ if ('production' !== process.env.NODE_ENV) {
|
|
|
58
58
|
var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
|
|
59
59
|
var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
process.env.NODE_ENV !== 'production' ? warning(idsIsArr === listenersIsArr && IDsLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : undefined;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -70,7 +70,7 @@ if ('production' !== process.env.NODE_ENV) {
|
|
|
70
70
|
function forEachEventDispatch(event, cb) {
|
|
71
71
|
var dispatchListeners = event._dispatchListeners;
|
|
72
72
|
var dispatchIDs = event._dispatchIDs;
|
|
73
|
-
if (
|
|
73
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
74
74
|
validateEventDispatches(event);
|
|
75
75
|
}
|
|
76
76
|
if (Array.isArray(dispatchListeners)) {
|
|
@@ -88,8 +88,8 @@ function forEachEventDispatch(event, cb) {
|
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Default implementation of PluginModule.executeDispatch().
|
|
91
|
-
* @param {SyntheticEvent} SyntheticEvent to handle
|
|
92
|
-
* @param {function} Application-level callback
|
|
91
|
+
* @param {SyntheticEvent} event SyntheticEvent to handle
|
|
92
|
+
* @param {function} listener Application-level callback
|
|
93
93
|
* @param {string} domID DOM id to pass to the callback.
|
|
94
94
|
*/
|
|
95
95
|
function executeDispatch(event, listener, domID) {
|
|
@@ -112,13 +112,13 @@ function executeDispatchesInOrder(event, cb) {
|
|
|
112
112
|
* Standard/simple iteration through an event's collected dispatches, but stops
|
|
113
113
|
* at the first dispatch execution returning true, and returns that id.
|
|
114
114
|
*
|
|
115
|
-
* @return id of the first dispatch execution who's listener returns
|
|
116
|
-
* null if no listener returned true.
|
|
115
|
+
* @return {?string} id of the first dispatch execution who's listener returns
|
|
116
|
+
* true, or null if no listener returned true.
|
|
117
117
|
*/
|
|
118
118
|
function executeDispatchesInOrderStopAtTrueImpl(event) {
|
|
119
119
|
var dispatchListeners = event._dispatchListeners;
|
|
120
120
|
var dispatchIDs = event._dispatchIDs;
|
|
121
|
-
if (
|
|
121
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
122
122
|
validateEventDispatches(event);
|
|
123
123
|
}
|
|
124
124
|
if (Array.isArray(dispatchListeners)) {
|
|
@@ -156,15 +156,15 @@ function executeDispatchesInOrderStopAtTrue(event) {
|
|
|
156
156
|
* return values at each dispatch execution, but it does tend to make sense when
|
|
157
157
|
* dealing with "direct" dispatches.
|
|
158
158
|
*
|
|
159
|
-
* @return The return value of executing the single dispatch.
|
|
159
|
+
* @return {*} The return value of executing the single dispatch.
|
|
160
160
|
*/
|
|
161
161
|
function executeDirectDispatch(event) {
|
|
162
|
-
if (
|
|
162
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
163
163
|
validateEventDispatches(event);
|
|
164
164
|
}
|
|
165
165
|
var dispatchListener = event._dispatchListeners;
|
|
166
166
|
var dispatchID = event._dispatchIDs;
|
|
167
|
-
|
|
167
|
+
!!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) : undefined;
|
|
168
168
|
var res = dispatchListener ? dispatchListener(event, dispatchID) : null;
|
|
169
169
|
event._dispatchListeners = null;
|
|
170
170
|
event._dispatchIDs = null;
|
|
@@ -173,7 +173,7 @@ function executeDirectDispatch(event) {
|
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* @param {SyntheticEvent} event
|
|
176
|
-
* @return {
|
|
176
|
+
* @return {boolean} True iff number of dispatches accumulated is greater than 0.
|
|
177
177
|
*/
|
|
178
178
|
function hasDispatches(event) {
|
|
179
179
|
return !!event._dispatchListeners;
|
package/lib/EventPropagators.js
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var EventConstants = require(
|
|
15
|
-
var EventPluginHub = require(
|
|
14
|
+
var EventConstants = require('./EventConstants');
|
|
15
|
+
var EventPluginHub = require('./EventPluginHub');
|
|
16
16
|
|
|
17
|
-
var warning = require(
|
|
17
|
+
var warning = require('fbjs/lib/warning');
|
|
18
18
|
|
|
19
|
-
var accumulateInto = require(
|
|
20
|
-
var forEachAccumulated = require(
|
|
19
|
+
var accumulateInto = require('./accumulateInto');
|
|
20
|
+
var forEachAccumulated = require('./forEachAccumulated');
|
|
21
21
|
|
|
22
22
|
var PropagationPhases = EventConstants.PropagationPhases;
|
|
23
23
|
var getListener = EventPluginHub.getListener;
|
|
@@ -38,8 +38,8 @@ function listenerAtPhase(id, event, propagationPhase) {
|
|
|
38
38
|
* "dispatch" object that pairs the event with the listener.
|
|
39
39
|
*/
|
|
40
40
|
function accumulateDirectionalDispatches(domID, upwards, event) {
|
|
41
|
-
if (
|
|
42
|
-
|
|
41
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
42
|
+
process.env.NODE_ENV !== 'production' ? warning(domID, 'Dispatching id must not be null') : undefined;
|
|
43
43
|
}
|
|
44
44
|
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
|
|
45
45
|
var listener = listenerAtPhase(domID, event, phase);
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var PooledClass = require(
|
|
15
|
+
var PooledClass = require('./PooledClass');
|
|
16
16
|
|
|
17
|
-
var assign = require(
|
|
18
|
-
var getTextContentAccessor = require(
|
|
17
|
+
var assign = require('./Object.assign');
|
|
18
|
+
var getTextContentAccessor = require('./getTextContentAccessor');
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* This helper class stores information about text content of a target node,
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var DOMProperty = require(
|
|
15
|
-
var ExecutionEnvironment = require(
|
|
14
|
+
var DOMProperty = require('./DOMProperty');
|
|
15
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
16
16
|
|
|
17
17
|
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
|
|
18
18
|
var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
|
|
@@ -43,12 +43,14 @@ var HTMLDOMPropertyConfig = {
|
|
|
43
43
|
alt: null,
|
|
44
44
|
async: HAS_BOOLEAN_VALUE,
|
|
45
45
|
autoComplete: null,
|
|
46
|
-
// autoFocus is polyfilled/normalized by
|
|
46
|
+
// autoFocus is polyfilled/normalized by AutoFocusUtils
|
|
47
47
|
// autoFocus: HAS_BOOLEAN_VALUE,
|
|
48
48
|
autoPlay: HAS_BOOLEAN_VALUE,
|
|
49
|
+
capture: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
|
49
50
|
cellPadding: null,
|
|
50
51
|
cellSpacing: null,
|
|
51
52
|
charSet: MUST_USE_ATTRIBUTE,
|
|
53
|
+
challenge: MUST_USE_ATTRIBUTE,
|
|
52
54
|
checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
|
53
55
|
classID: MUST_USE_ATTRIBUTE,
|
|
54
56
|
// To set className on SVG elements, it's necessary to use .setAttribute;
|
|
@@ -90,6 +92,10 @@ var HTMLDOMPropertyConfig = {
|
|
|
90
92
|
httpEquiv: null,
|
|
91
93
|
icon: null,
|
|
92
94
|
id: MUST_USE_PROPERTY,
|
|
95
|
+
inputMode: MUST_USE_ATTRIBUTE,
|
|
96
|
+
is: MUST_USE_ATTRIBUTE,
|
|
97
|
+
keyParams: MUST_USE_ATTRIBUTE,
|
|
98
|
+
keyType: MUST_USE_ATTRIBUTE,
|
|
93
99
|
label: null,
|
|
94
100
|
lang: null,
|
|
95
101
|
list: MUST_USE_ATTRIBUTE,
|
|
@@ -147,6 +153,7 @@ var HTMLDOMPropertyConfig = {
|
|
|
147
153
|
value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
|
|
148
154
|
width: MUST_USE_ATTRIBUTE,
|
|
149
155
|
wmode: MUST_USE_ATTRIBUTE,
|
|
156
|
+
wrap: null,
|
|
150
157
|
|
|
151
158
|
/**
|
|
152
159
|
* Non-standard Properties
|
|
@@ -167,6 +174,9 @@ var HTMLDOMPropertyConfig = {
|
|
|
167
174
|
itemRef: MUST_USE_ATTRIBUTE,
|
|
168
175
|
// property is supported for OpenGraph in meta tags.
|
|
169
176
|
property: null,
|
|
177
|
+
// IE-only attribute that specifies security restrictions on an iframe
|
|
178
|
+
// as an alternative to the sandbox attribute on IE<10
|
|
179
|
+
security: MUST_USE_ATTRIBUTE,
|
|
170
180
|
// IE-only attribute that controls focus behavior
|
|
171
181
|
unselectable: MUST_USE_ATTRIBUTE
|
|
172
182
|
},
|
package/lib/LinkedStateMixin.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var ReactLink = require(
|
|
16
|
-
var ReactStateSetters = require(
|
|
15
|
+
var ReactLink = require('./ReactLink');
|
|
16
|
+
var ReactStateSetters = require('./ReactStateSetters');
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* A simple mixin around ReactLink.forState().
|
package/lib/LinkedValueUtils.js
CHANGED
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var ReactPropTypes = require(
|
|
15
|
+
var ReactPropTypes = require('./ReactPropTypes');
|
|
16
|
+
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
16
17
|
|
|
17
|
-
var invariant = require(
|
|
18
|
+
var invariant = require('fbjs/lib/invariant');
|
|
19
|
+
var warning = require('fbjs/lib/warning');
|
|
18
20
|
|
|
19
21
|
var hasReadOnlyValue = {
|
|
20
22
|
'button': true,
|
|
@@ -27,32 +29,43 @@ var hasReadOnlyValue = {
|
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
function _assertSingleLink(inputProps) {
|
|
30
|
-
|
|
32
|
+
!(inputProps.checkedLink == null || inputProps.valueLink == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a valueLink. If you want to use ' + 'checkedLink, you probably don\'t want to use valueLink and vice versa.') : invariant(false) : undefined;
|
|
31
33
|
}
|
|
32
34
|
function _assertValueLink(inputProps) {
|
|
33
35
|
_assertSingleLink(inputProps);
|
|
34
|
-
|
|
36
|
+
!(inputProps.value == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a valueLink and a value or onChange event. If you want ' + 'to use value or onChange, you probably don\'t want to use valueLink.') : invariant(false) : undefined;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
function _assertCheckedLink(inputProps) {
|
|
38
40
|
_assertSingleLink(inputProps);
|
|
39
|
-
|
|
41
|
+
!(inputProps.checked == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a checked property or onChange event. ' + 'If you want to use checked or onChange, you probably don\'t want to ' + 'use checkedLink') : invariant(false) : undefined;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
44
|
+
var propTypes = {
|
|
45
|
+
value: function (props, propName, componentName) {
|
|
46
|
+
if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
|
|
50
|
+
},
|
|
51
|
+
checked: function (props, propName, componentName) {
|
|
52
|
+
if (!props[propName] || props.onChange || props.readOnly || props.disabled) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
|
|
56
|
+
},
|
|
57
|
+
onChange: ReactPropTypes.func
|
|
58
|
+
};
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
var loggedTypeFailures = {};
|
|
61
|
+
function getDeclarationErrorAddendum(owner) {
|
|
62
|
+
if (owner) {
|
|
63
|
+
var name = owner.getName();
|
|
64
|
+
if (name) {
|
|
65
|
+
return ' Check the render method of `' + name + '`.';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return '';
|
|
56
69
|
}
|
|
57
70
|
|
|
58
71
|
/**
|
|
@@ -60,21 +73,19 @@ function _handleLinkedCheckChange(e) {
|
|
|
60
73
|
* this outside of the ReactDOM controlled form components.
|
|
61
74
|
*/
|
|
62
75
|
var LinkedValueUtils = {
|
|
63
|
-
|
|
64
|
-
propTypes
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
onChange: ReactPropTypes.func
|
|
76
|
+
checkPropTypes: function (tagName, props, owner) {
|
|
77
|
+
for (var propName in propTypes) {
|
|
78
|
+
if (propTypes.hasOwnProperty(propName)) {
|
|
79
|
+
var error = propTypes[propName](props, propName, tagName, ReactPropTypeLocations.prop);
|
|
80
|
+
}
|
|
81
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
82
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
83
|
+
// same error.
|
|
84
|
+
loggedTypeFailures[error.message] = true;
|
|
85
|
+
|
|
86
|
+
var addendum = getDeclarationErrorAddendum(owner);
|
|
87
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed form propType: %s%s', error.message, addendum) : undefined;
|
|
88
|
+
}
|
|
78
89
|
}
|
|
79
90
|
},
|
|
80
91
|
|
|
@@ -105,17 +116,18 @@ var LinkedValueUtils = {
|
|
|
105
116
|
|
|
106
117
|
/**
|
|
107
118
|
* @param {object} inputProps Props for form component
|
|
108
|
-
* @
|
|
119
|
+
* @param {SyntheticEvent} event change event to handle
|
|
109
120
|
*/
|
|
110
|
-
|
|
121
|
+
executeOnChange: function (inputProps, event) {
|
|
111
122
|
if (inputProps.valueLink) {
|
|
112
123
|
_assertValueLink(inputProps);
|
|
113
|
-
return
|
|
124
|
+
return inputProps.valueLink.requestChange(event.target.value);
|
|
114
125
|
} else if (inputProps.checkedLink) {
|
|
115
126
|
_assertCheckedLink(inputProps);
|
|
116
|
-
return
|
|
127
|
+
return inputProps.checkedLink.requestChange(event.target.checked);
|
|
128
|
+
} else if (inputProps.onChange) {
|
|
129
|
+
return inputProps.onChange.call(undefined, event);
|
|
117
130
|
}
|
|
118
|
-
return inputProps.onChange;
|
|
119
131
|
}
|
|
120
132
|
};
|
|
121
133
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
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.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule MetaMatchers
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This modules adds a jasmine matcher toEqualSpecsIn that can be used to
|
|
16
|
+
* compare the specs in two different "describe" functions and their result.
|
|
17
|
+
* It can be used to test a test.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function getRunnerWithResults(describeFunction) {
|
|
21
|
+
if (describeFunction._cachedRunner) {
|
|
22
|
+
// Cached result of execution. This is a convenience way to test against
|
|
23
|
+
// the same authorative function multiple times.
|
|
24
|
+
return describeFunction._cachedRunner;
|
|
25
|
+
}
|
|
26
|
+
// Patch the current global environment.
|
|
27
|
+
var env = new jasmine.Env();
|
|
28
|
+
// Execute the tests synchronously.
|
|
29
|
+
env.updateInterval = 0;
|
|
30
|
+
var outerGetEnv = jasmine.getEnv;
|
|
31
|
+
jasmine.getEnv = function () {
|
|
32
|
+
return env;
|
|
33
|
+
};
|
|
34
|
+
// TODO: Bring over matchers from the existing environment.
|
|
35
|
+
var runner = env.currentRunner();
|
|
36
|
+
try {
|
|
37
|
+
env.describe('', describeFunction);
|
|
38
|
+
env.execute();
|
|
39
|
+
} finally {
|
|
40
|
+
// Restore the environment.
|
|
41
|
+
jasmine.getEnv = outerGetEnv;
|
|
42
|
+
}
|
|
43
|
+
describeFunction._cachedRunner = runner;
|
|
44
|
+
return runner;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function compareSpec(actual, expected) {
|
|
48
|
+
if (actual.results().totalCount !== expected.results().totalCount) {
|
|
49
|
+
return 'Expected ' + expected.results().totalCount + ' expects, ' + 'but got ' + actual.results().totalCount + ':' + actual.getFullName();
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function includesDescription(specs, description, startIndex) {
|
|
55
|
+
for (var i = startIndex; i < specs.length; i++) {
|
|
56
|
+
if (specs[i].description === description) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function compareSpecs(actualSpecs, expectedSpecs) {
|
|
64
|
+
for (var i = 0; i < actualSpecs.length && i < expectedSpecs.length; i++) {
|
|
65
|
+
var actual = actualSpecs[i];
|
|
66
|
+
var expected = expectedSpecs[i];
|
|
67
|
+
if (actual.description === expected.description) {
|
|
68
|
+
var errorMessage = compareSpec(actual, expected);
|
|
69
|
+
if (errorMessage) {
|
|
70
|
+
return errorMessage;
|
|
71
|
+
}
|
|
72
|
+
continue;
|
|
73
|
+
} else if (includesDescription(actualSpecs, expected.description, i)) {
|
|
74
|
+
return 'Did not expect the spec:' + actualSpecs[i].getFullName();
|
|
75
|
+
} else {
|
|
76
|
+
return 'Expected an equivalent to:' + expectedSpecs[i].getFullName();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (i < actualSpecs.length) {
|
|
80
|
+
return 'Did not expect the spec:' + actualSpecs[i].getFullName();
|
|
81
|
+
}
|
|
82
|
+
if (i < expectedSpecs.length) {
|
|
83
|
+
return 'Expected an equivalent to:' + expectedSpecs[i].getFullName();
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function compareDescription(a, b) {
|
|
89
|
+
if (a.description === b.description) {
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
return a.description < b.description ? -1 : 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function compareRunners(actual, expected) {
|
|
96
|
+
return compareSpecs(actual.specs().sort(compareDescription), expected.specs().sort(compareDescription));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var MetaMatchers = {
|
|
100
|
+
toEqualSpecsIn: function (expectedDescribeFunction) {
|
|
101
|
+
var actualDescribeFunction = this.actual;
|
|
102
|
+
if (typeof actualDescribeFunction !== 'function') {
|
|
103
|
+
throw Error('toEqualSpecsIn() should be used on a describe function');
|
|
104
|
+
}
|
|
105
|
+
if (typeof expectedDescribeFunction !== 'function') {
|
|
106
|
+
throw Error('toEqualSpecsIn() should be passed a describe function');
|
|
107
|
+
}
|
|
108
|
+
var actual = getRunnerWithResults(actualDescribeFunction);
|
|
109
|
+
var expected = getRunnerWithResults(expectedDescribeFunction);
|
|
110
|
+
var errorMessage = compareRunners(actual, expected);
|
|
111
|
+
this.message = function () {
|
|
112
|
+
return [errorMessage, 'The specs are equal. Expected them to be different.'];
|
|
113
|
+
};
|
|
114
|
+
return !errorMessage;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
module.exports = MetaMatchers;
|