react 0.12.0 → 0.13.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/JSXTransformer.js +2345 -910
  2. package/dist/react-with-addons.js +5273 -4111
  3. package/dist/react-with-addons.min.js +5 -6
  4. package/dist/react.js +4840 -3940
  5. package/dist/react.min.js +5 -6
  6. package/lib/AutoFocusMixin.js +1 -1
  7. package/lib/BeforeInputEventPlugin.js +389 -112
  8. package/lib/CSSProperty.js +6 -3
  9. package/lib/CSSPropertyOperations.js +21 -1
  10. package/lib/CallbackQueue.js +2 -2
  11. package/lib/ChangeEventPlugin.js +3 -3
  12. package/lib/ClientReactRootIndex.js +1 -1
  13. package/lib/DOMChildrenOperations.js +6 -4
  14. package/lib/DOMProperty.js +1 -1
  15. package/lib/DOMPropertyOperations.js +1 -1
  16. package/lib/Danger.js +7 -6
  17. package/lib/DefaultEventPluginOrder.js +1 -2
  18. package/lib/EnterLeaveEventPlugin.js +1 -1
  19. package/lib/EventConstants.js +1 -1
  20. package/lib/EventPluginHub.js +9 -7
  21. package/lib/EventPluginRegistry.js +1 -1
  22. package/lib/EventPluginUtils.js +1 -1
  23. package/lib/EventPropagators.js +1 -1
  24. package/lib/ExecutionEnvironment.js +2 -3
  25. package/lib/FallbackCompositionState.js +89 -0
  26. package/lib/HTMLDOMPropertyConfig.js +19 -7
  27. package/lib/LinkedStateMixin.js +1 -1
  28. package/lib/LinkedValueUtils.js +3 -3
  29. package/lib/LocalEventTrapMixin.js +1 -1
  30. package/lib/MobileSafariClickEventPlugin.js +1 -1
  31. package/lib/Object.assign.js +3 -1
  32. package/lib/PooledClass.js +1 -1
  33. package/lib/React.js +17 -50
  34. package/lib/ReactBrowserComponentMixin.js +3 -13
  35. package/lib/ReactBrowserEventEmitter.js +4 -6
  36. package/lib/ReactCSSTransitionGroup.js +4 -1
  37. package/lib/ReactCSSTransitionGroupChild.js +12 -2
  38. package/lib/ReactChildReconciler.js +121 -0
  39. package/lib/ReactChildren.js +10 -8
  40. package/lib/ReactClass.js +874 -0
  41. package/lib/ReactComponent.js +45 -286
  42. package/lib/ReactComponentBase.js +126 -0
  43. package/lib/ReactComponentBrowserEnvironment.js +10 -83
  44. package/lib/ReactComponentEnvironment.js +57 -0
  45. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  46. package/lib/ReactCompositeComponent.js +700 -1045
  47. package/lib/ReactContext.js +6 -2
  48. package/lib/ReactCurrentOwner.js +1 -1
  49. package/lib/ReactDOM.js +3 -8
  50. package/lib/ReactDOMButton.js +5 -6
  51. package/lib/ReactDOMComponent.js +120 -77
  52. package/lib/ReactDOMForm.js +5 -6
  53. package/lib/ReactDOMIDOperations.js +56 -74
  54. package/lib/ReactDOMImg.js +4 -6
  55. package/lib/ReactDOMInput.js +5 -6
  56. package/lib/ReactDOMOption.js +5 -6
  57. package/lib/ReactDOMSelect.js +57 -65
  58. package/lib/ReactDOMSelection.js +6 -2
  59. package/lib/ReactDOMTextComponent.js +124 -0
  60. package/lib/ReactDOMTextarea.js +5 -6
  61. package/lib/ReactDefaultBatchingStrategy.js +1 -1
  62. package/lib/ReactDefaultInjection.js +14 -8
  63. package/lib/ReactDefaultPerf.js +8 -7
  64. package/lib/ReactDefaultPerfAnalysis.js +1 -1
  65. package/lib/ReactElement.js +22 -15
  66. package/lib/ReactElementValidator.js +192 -53
  67. package/lib/ReactEmptyComponent.js +29 -11
  68. package/lib/ReactEventEmitterMixin.js +1 -1
  69. package/lib/ReactEventListener.js +3 -3
  70. package/lib/ReactInjection.js +7 -5
  71. package/lib/ReactInputSelection.js +3 -4
  72. package/lib/ReactInstanceHandles.js +3 -2
  73. package/lib/ReactInstanceMap.js +47 -0
  74. package/lib/ReactLink.js +1 -1
  75. package/lib/ReactMarkupChecksum.js +1 -1
  76. package/lib/ReactMount.js +202 -66
  77. package/lib/ReactMultiChild.js +44 -45
  78. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  79. package/lib/ReactNativeComponent.js +47 -10
  80. package/lib/ReactOwner.js +4 -48
  81. package/lib/ReactPerf.js +21 -1
  82. package/lib/ReactPropTransferer.js +2 -57
  83. package/lib/ReactPropTypeLocationNames.js +1 -1
  84. package/lib/ReactPropTypeLocations.js +1 -1
  85. package/lib/ReactPropTypes.js +14 -22
  86. package/lib/ReactPutListenerQueue.js +1 -1
  87. package/lib/ReactReconcileTransaction.js +1 -1
  88. package/lib/ReactRef.js +96 -0
  89. package/lib/ReactRootIndex.js +1 -1
  90. package/lib/ReactServerRendering.js +5 -3
  91. package/lib/ReactServerRenderingTransaction.js +1 -1
  92. package/lib/ReactStateSetters.js +1 -1
  93. package/lib/ReactTestUtils.js +83 -26
  94. package/lib/ReactTransitionChildMapping.js +1 -1
  95. package/lib/ReactTransitionEvents.js +1 -1
  96. package/lib/ReactTransitionGroup.js +48 -7
  97. package/lib/ReactUpdates.js +46 -45
  98. package/lib/ReactWithAddons.js +1 -1
  99. package/lib/SVGDOMPropertyConfig.js +1 -1
  100. package/lib/SelectEventPlugin.js +3 -3
  101. package/lib/ServerReactRootIndex.js +1 -1
  102. package/lib/SimpleEventPlugin.js +1 -1
  103. package/lib/SyntheticClipboardEvent.js +1 -2
  104. package/lib/SyntheticCompositionEvent.js +1 -2
  105. package/lib/SyntheticDragEvent.js +1 -1
  106. package/lib/SyntheticEvent.js +11 -3
  107. package/lib/SyntheticFocusEvent.js +1 -1
  108. package/lib/SyntheticInputEvent.js +1 -2
  109. package/lib/SyntheticKeyboardEvent.js +1 -1
  110. package/lib/SyntheticMouseEvent.js +2 -4
  111. package/lib/SyntheticTouchEvent.js +1 -1
  112. package/lib/SyntheticUIEvent.js +1 -1
  113. package/lib/SyntheticWheelEvent.js +1 -1
  114. package/lib/Transaction.js +3 -3
  115. package/lib/ViewportMetrics.js +2 -5
  116. package/lib/accumulate.js +47 -0
  117. package/lib/accumulateInto.js +1 -1
  118. package/lib/adler32.js +1 -1
  119. package/lib/cloneWithProps.js +3 -3
  120. package/lib/copyProperties.js +2 -0
  121. package/lib/createFullPageComponent.js +3 -3
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/escapeTextForBrowser.js +6 -6
  124. package/lib/findDOMNode.js +51 -0
  125. package/lib/flattenChildren.js +11 -22
  126. package/lib/forEachAccumulated.js +1 -1
  127. package/lib/getEventCharCode.js +1 -1
  128. package/lib/getEventKey.js +1 -1
  129. package/lib/getEventModifierState.js +1 -1
  130. package/lib/getEventTarget.js +1 -1
  131. package/lib/getIteratorFn.js +42 -0
  132. package/lib/getNodeForCharacterOffset.js +2 -2
  133. package/lib/getReactRootElementInContainer.js +1 -1
  134. package/lib/getTextContentAccessor.js +1 -1
  135. package/lib/instantiateReactComponent.js +89 -66
  136. package/lib/isEventSupported.js +1 -1
  137. package/lib/isNode.js +3 -4
  138. package/lib/isTextInputElement.js +2 -3
  139. package/lib/joinClasses.js +1 -1
  140. package/lib/keyMirror.js +1 -1
  141. package/lib/memoizeStringOnly.js +4 -5
  142. package/lib/onlyChild.js +1 -1
  143. package/lib/setInnerHTML.js +12 -1
  144. package/lib/shallowEqual.js +1 -1
  145. package/lib/shouldUpdateReactComponent.js +48 -6
  146. package/lib/traverseAllChildren.js +111 -55
  147. package/lib/update.js +1 -1
  148. package/lib/warning.js +9 -2
  149. package/package.json +1 -1
  150. package/lib/CompositionEventPlugin.js +0 -257
  151. package/lib/ReactLegacyElement.js +0 -243
  152. package/lib/ReactTextComponent.js +0 -104
  153. package/lib/deprecated.js +0 -47
@@ -1,257 +0,0 @@
1
- /**
2
- * Copyright 2013-2014, 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 CompositionEventPlugin
10
- * @typechecks static-only
11
- */
12
-
13
- "use strict";
14
-
15
- var EventConstants = require("./EventConstants");
16
- var EventPropagators = require("./EventPropagators");
17
- var ExecutionEnvironment = require("./ExecutionEnvironment");
18
- var ReactInputSelection = require("./ReactInputSelection");
19
- var SyntheticCompositionEvent = require("./SyntheticCompositionEvent");
20
-
21
- var getTextContentAccessor = require("./getTextContentAccessor");
22
- var keyOf = require("./keyOf");
23
-
24
- var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
25
- var START_KEYCODE = 229;
26
-
27
- var useCompositionEvent = (
28
- ExecutionEnvironment.canUseDOM &&
29
- 'CompositionEvent' in window
30
- );
31
-
32
- // In IE9+, we have access to composition events, but the data supplied
33
- // by the native compositionend event may be incorrect. In Korean, for example,
34
- // the compositionend event contains only one character regardless of
35
- // how many characters have been composed since compositionstart.
36
- // We therefore use the fallback data while still using the native
37
- // events as triggers.
38
- var useFallbackData = (
39
- !useCompositionEvent ||
40
- (
41
- 'documentMode' in document &&
42
- document.documentMode > 8 &&
43
- document.documentMode <= 11
44
- )
45
- );
46
-
47
- var topLevelTypes = EventConstants.topLevelTypes;
48
- var currentComposition = null;
49
-
50
- // Events and their corresponding property names.
51
- var eventTypes = {
52
- compositionEnd: {
53
- phasedRegistrationNames: {
54
- bubbled: keyOf({onCompositionEnd: null}),
55
- captured: keyOf({onCompositionEndCapture: null})
56
- },
57
- dependencies: [
58
- topLevelTypes.topBlur,
59
- topLevelTypes.topCompositionEnd,
60
- topLevelTypes.topKeyDown,
61
- topLevelTypes.topKeyPress,
62
- topLevelTypes.topKeyUp,
63
- topLevelTypes.topMouseDown
64
- ]
65
- },
66
- compositionStart: {
67
- phasedRegistrationNames: {
68
- bubbled: keyOf({onCompositionStart: null}),
69
- captured: keyOf({onCompositionStartCapture: null})
70
- },
71
- dependencies: [
72
- topLevelTypes.topBlur,
73
- topLevelTypes.topCompositionStart,
74
- topLevelTypes.topKeyDown,
75
- topLevelTypes.topKeyPress,
76
- topLevelTypes.topKeyUp,
77
- topLevelTypes.topMouseDown
78
- ]
79
- },
80
- compositionUpdate: {
81
- phasedRegistrationNames: {
82
- bubbled: keyOf({onCompositionUpdate: null}),
83
- captured: keyOf({onCompositionUpdateCapture: null})
84
- },
85
- dependencies: [
86
- topLevelTypes.topBlur,
87
- topLevelTypes.topCompositionUpdate,
88
- topLevelTypes.topKeyDown,
89
- topLevelTypes.topKeyPress,
90
- topLevelTypes.topKeyUp,
91
- topLevelTypes.topMouseDown
92
- ]
93
- }
94
- };
95
-
96
- /**
97
- * Translate native top level events into event types.
98
- *
99
- * @param {string} topLevelType
100
- * @return {object}
101
- */
102
- function getCompositionEventType(topLevelType) {
103
- switch (topLevelType) {
104
- case topLevelTypes.topCompositionStart:
105
- return eventTypes.compositionStart;
106
- case topLevelTypes.topCompositionEnd:
107
- return eventTypes.compositionEnd;
108
- case topLevelTypes.topCompositionUpdate:
109
- return eventTypes.compositionUpdate;
110
- }
111
- }
112
-
113
- /**
114
- * Does our fallback best-guess model think this event signifies that
115
- * composition has begun?
116
- *
117
- * @param {string} topLevelType
118
- * @param {object} nativeEvent
119
- * @return {boolean}
120
- */
121
- function isFallbackStart(topLevelType, nativeEvent) {
122
- return (
123
- topLevelType === topLevelTypes.topKeyDown &&
124
- nativeEvent.keyCode === START_KEYCODE
125
- );
126
- }
127
-
128
- /**
129
- * Does our fallback mode think that this event is the end of composition?
130
- *
131
- * @param {string} topLevelType
132
- * @param {object} nativeEvent
133
- * @return {boolean}
134
- */
135
- function isFallbackEnd(topLevelType, nativeEvent) {
136
- switch (topLevelType) {
137
- case topLevelTypes.topKeyUp:
138
- // Command keys insert or clear IME input.
139
- return (END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1);
140
- case topLevelTypes.topKeyDown:
141
- // Expect IME keyCode on each keydown. If we get any other
142
- // code we must have exited earlier.
143
- return (nativeEvent.keyCode !== START_KEYCODE);
144
- case topLevelTypes.topKeyPress:
145
- case topLevelTypes.topMouseDown:
146
- case topLevelTypes.topBlur:
147
- // Events are not possible without cancelling IME.
148
- return true;
149
- default:
150
- return false;
151
- }
152
- }
153
-
154
- /**
155
- * Helper class stores information about selection and document state
156
- * so we can figure out what changed at a later date.
157
- *
158
- * @param {DOMEventTarget} root
159
- */
160
- function FallbackCompositionState(root) {
161
- this.root = root;
162
- this.startSelection = ReactInputSelection.getSelection(root);
163
- this.startValue = this.getText();
164
- }
165
-
166
- /**
167
- * Get current text of input.
168
- *
169
- * @return {string}
170
- */
171
- FallbackCompositionState.prototype.getText = function() {
172
- return this.root.value || this.root[getTextContentAccessor()];
173
- };
174
-
175
- /**
176
- * Text that has changed since the start of composition.
177
- *
178
- * @return {string}
179
- */
180
- FallbackCompositionState.prototype.getData = function() {
181
- var endValue = this.getText();
182
- var prefixLength = this.startSelection.start;
183
- var suffixLength = this.startValue.length - this.startSelection.end;
184
-
185
- return endValue.substr(
186
- prefixLength,
187
- endValue.length - suffixLength - prefixLength
188
- );
189
- };
190
-
191
- /**
192
- * This plugin creates `onCompositionStart`, `onCompositionUpdate` and
193
- * `onCompositionEnd` events on inputs, textareas and contentEditable
194
- * nodes.
195
- */
196
- var CompositionEventPlugin = {
197
-
198
- eventTypes: eventTypes,
199
-
200
- /**
201
- * @param {string} topLevelType Record from `EventConstants`.
202
- * @param {DOMEventTarget} topLevelTarget The listening component root node.
203
- * @param {string} topLevelTargetID ID of `topLevelTarget`.
204
- * @param {object} nativeEvent Native browser event.
205
- * @return {*} An accumulation of synthetic events.
206
- * @see {EventPluginHub.extractEvents}
207
- */
208
- extractEvents: function(
209
- topLevelType,
210
- topLevelTarget,
211
- topLevelTargetID,
212
- nativeEvent) {
213
-
214
- var eventType;
215
- var data;
216
-
217
- if (useCompositionEvent) {
218
- eventType = getCompositionEventType(topLevelType);
219
- } else if (!currentComposition) {
220
- if (isFallbackStart(topLevelType, nativeEvent)) {
221
- eventType = eventTypes.compositionStart;
222
- }
223
- } else if (isFallbackEnd(topLevelType, nativeEvent)) {
224
- eventType = eventTypes.compositionEnd;
225
- }
226
-
227
- if (useFallbackData) {
228
- // The current composition is stored statically and must not be
229
- // overwritten while composition continues.
230
- if (!currentComposition && eventType === eventTypes.compositionStart) {
231
- currentComposition = new FallbackCompositionState(topLevelTarget);
232
- } else if (eventType === eventTypes.compositionEnd) {
233
- if (currentComposition) {
234
- data = currentComposition.getData();
235
- currentComposition = null;
236
- }
237
- }
238
- }
239
-
240
- if (eventType) {
241
- var event = SyntheticCompositionEvent.getPooled(
242
- eventType,
243
- topLevelTargetID,
244
- nativeEvent
245
- );
246
- if (data) {
247
- // Inject data generated from fallback path into the synthetic event.
248
- // This matches the property of native CompositionEventInterface.
249
- event.data = data;
250
- }
251
- EventPropagators.accumulateTwoPhaseDispatches(event);
252
- return event;
253
- }
254
- }
255
- };
256
-
257
- module.exports = CompositionEventPlugin;
@@ -1,243 +0,0 @@
1
- /**
2
- * Copyright 2014, 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 ReactLegacyElement
10
- */
11
-
12
- "use strict";
13
-
14
- var ReactCurrentOwner = require("./ReactCurrentOwner");
15
-
16
- var invariant = require("./invariant");
17
- var monitorCodeUse = require("./monitorCodeUse");
18
- var warning = require("./warning");
19
-
20
- var legacyFactoryLogs = {};
21
- function warnForLegacyFactoryCall() {
22
- if (!ReactLegacyElementFactory._isLegacyCallWarningEnabled) {
23
- return;
24
- }
25
- var owner = ReactCurrentOwner.current;
26
- var name = owner && owner.constructor ? owner.constructor.displayName : '';
27
- if (!name) {
28
- name = 'Something';
29
- }
30
- if (legacyFactoryLogs.hasOwnProperty(name)) {
31
- return;
32
- }
33
- legacyFactoryLogs[name] = true;
34
- ("production" !== process.env.NODE_ENV ? warning(
35
- false,
36
- name + ' is calling a React component directly. ' +
37
- 'Use a factory or JSX instead. See: http://fb.me/react-legacyfactory'
38
- ) : null);
39
- monitorCodeUse('react_legacy_factory_call', { version: 3, name: name });
40
- }
41
-
42
- function warnForPlainFunctionType(type) {
43
- var isReactClass =
44
- type.prototype &&
45
- typeof type.prototype.mountComponent === 'function' &&
46
- typeof type.prototype.receiveComponent === 'function';
47
- if (isReactClass) {
48
- ("production" !== process.env.NODE_ENV ? warning(
49
- false,
50
- 'Did not expect to get a React class here. Use `Component` instead ' +
51
- 'of `Component.type` or `this.constructor`.'
52
- ) : null);
53
- } else {
54
- if (!type._reactWarnedForThisType) {
55
- try {
56
- type._reactWarnedForThisType = true;
57
- } catch (x) {
58
- // just incase this is a frozen object or some special object
59
- }
60
- monitorCodeUse(
61
- 'react_non_component_in_jsx',
62
- { version: 3, name: type.name }
63
- );
64
- }
65
- ("production" !== process.env.NODE_ENV ? warning(
66
- false,
67
- 'This JSX uses a plain function. Only React components are ' +
68
- 'valid in React\'s JSX transform.'
69
- ) : null);
70
- }
71
- }
72
-
73
- function warnForNonLegacyFactory(type) {
74
- ("production" !== process.env.NODE_ENV ? warning(
75
- false,
76
- 'Do not pass React.DOM.' + type.type + ' to JSX or createFactory. ' +
77
- 'Use the string "' + type.type + '" instead.'
78
- ) : null);
79
- }
80
-
81
- /**
82
- * Transfer static properties from the source to the target. Functions are
83
- * rebound to have this reflect the original source.
84
- */
85
- function proxyStaticMethods(target, source) {
86
- if (typeof source !== 'function') {
87
- return;
88
- }
89
- for (var key in source) {
90
- if (source.hasOwnProperty(key)) {
91
- var value = source[key];
92
- if (typeof value === 'function') {
93
- var bound = value.bind(source);
94
- // Copy any properties defined on the function, such as `isRequired` on
95
- // a PropTypes validator.
96
- for (var k in value) {
97
- if (value.hasOwnProperty(k)) {
98
- bound[k] = value[k];
99
- }
100
- }
101
- target[key] = bound;
102
- } else {
103
- target[key] = value;
104
- }
105
- }
106
- }
107
- }
108
-
109
- // We use an object instead of a boolean because booleans are ignored by our
110
- // mocking libraries when these factories gets mocked.
111
- var LEGACY_MARKER = {};
112
- var NON_LEGACY_MARKER = {};
113
-
114
- var ReactLegacyElementFactory = {};
115
-
116
- ReactLegacyElementFactory.wrapCreateFactory = function(createFactory) {
117
- var legacyCreateFactory = function(type) {
118
- if (typeof type !== 'function') {
119
- // Non-function types cannot be legacy factories
120
- return createFactory(type);
121
- }
122
-
123
- if (type.isReactNonLegacyFactory) {
124
- // This is probably a factory created by ReactDOM we unwrap it to get to
125
- // the underlying string type. It shouldn't have been passed here so we
126
- // warn.
127
- if ("production" !== process.env.NODE_ENV) {
128
- warnForNonLegacyFactory(type);
129
- }
130
- return createFactory(type.type);
131
- }
132
-
133
- if (type.isReactLegacyFactory) {
134
- // This is probably a legacy factory created by ReactCompositeComponent.
135
- // We unwrap it to get to the underlying class.
136
- return createFactory(type.type);
137
- }
138
-
139
- if ("production" !== process.env.NODE_ENV) {
140
- warnForPlainFunctionType(type);
141
- }
142
-
143
- // Unless it's a legacy factory, then this is probably a plain function,
144
- // that is expecting to be invoked by JSX. We can just return it as is.
145
- return type;
146
- };
147
- return legacyCreateFactory;
148
- };
149
-
150
- ReactLegacyElementFactory.wrapCreateElement = function(createElement) {
151
- var legacyCreateElement = function(type, props, children) {
152
- if (typeof type !== 'function') {
153
- // Non-function types cannot be legacy factories
154
- return createElement.apply(this, arguments);
155
- }
156
-
157
- var args;
158
-
159
- if (type.isReactNonLegacyFactory) {
160
- // This is probably a factory created by ReactDOM we unwrap it to get to
161
- // the underlying string type. It shouldn't have been passed here so we
162
- // warn.
163
- if ("production" !== process.env.NODE_ENV) {
164
- warnForNonLegacyFactory(type);
165
- }
166
- args = Array.prototype.slice.call(arguments, 0);
167
- args[0] = type.type;
168
- return createElement.apply(this, args);
169
- }
170
-
171
- if (type.isReactLegacyFactory) {
172
- // This is probably a legacy factory created by ReactCompositeComponent.
173
- // We unwrap it to get to the underlying class.
174
- if (type._isMockFunction) {
175
- // If this is a mock function, people will expect it to be called. We
176
- // will actually call the original mock factory function instead. This
177
- // future proofs unit testing that assume that these are classes.
178
- type.type._mockedReactClassConstructor = type;
179
- }
180
- args = Array.prototype.slice.call(arguments, 0);
181
- args[0] = type.type;
182
- return createElement.apply(this, args);
183
- }
184
-
185
- if ("production" !== process.env.NODE_ENV) {
186
- warnForPlainFunctionType(type);
187
- }
188
-
189
- // This is being called with a plain function we should invoke it
190
- // immediately as if this was used with legacy JSX.
191
- return type.apply(null, Array.prototype.slice.call(arguments, 1));
192
- };
193
- return legacyCreateElement;
194
- };
195
-
196
- ReactLegacyElementFactory.wrapFactory = function(factory) {
197
- ("production" !== process.env.NODE_ENV ? invariant(
198
- typeof factory === 'function',
199
- 'This is suppose to accept a element factory'
200
- ) : invariant(typeof factory === 'function'));
201
- var legacyElementFactory = function(config, children) {
202
- // This factory should not be called when JSX is used. Use JSX instead.
203
- if ("production" !== process.env.NODE_ENV) {
204
- warnForLegacyFactoryCall();
205
- }
206
- return factory.apply(this, arguments);
207
- };
208
- proxyStaticMethods(legacyElementFactory, factory.type);
209
- legacyElementFactory.isReactLegacyFactory = LEGACY_MARKER;
210
- legacyElementFactory.type = factory.type;
211
- return legacyElementFactory;
212
- };
213
-
214
- // This is used to mark a factory that will remain. E.g. we're allowed to call
215
- // it as a function. However, you're not suppose to pass it to createElement
216
- // or createFactory, so it will warn you if you do.
217
- ReactLegacyElementFactory.markNonLegacyFactory = function(factory) {
218
- factory.isReactNonLegacyFactory = NON_LEGACY_MARKER;
219
- return factory;
220
- };
221
-
222
- // Checks if a factory function is actually a legacy factory pretending to
223
- // be a class.
224
- ReactLegacyElementFactory.isValidFactory = function(factory) {
225
- // TODO: This will be removed and moved into a class validator or something.
226
- return typeof factory === 'function' &&
227
- factory.isReactLegacyFactory === LEGACY_MARKER;
228
- };
229
-
230
- ReactLegacyElementFactory.isValidClass = function(factory) {
231
- if ("production" !== process.env.NODE_ENV) {
232
- ("production" !== process.env.NODE_ENV ? warning(
233
- false,
234
- 'isValidClass is deprecated and will be removed in a future release. ' +
235
- 'Use a more specific validator instead.'
236
- ) : null);
237
- }
238
- return ReactLegacyElementFactory.isValidFactory(factory);
239
- };
240
-
241
- ReactLegacyElementFactory._isLegacyCallWarningEnabled = true;
242
-
243
- module.exports = ReactLegacyElementFactory;