react 0.11.2 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/JSXTransformer.js +2714 -7859
- package/dist/react-with-addons.js +3139 -3593
- package/dist/react-with-addons.min.js +11 -17
- package/dist/react.js +2940 -3308
- package/dist/react.min.js +11 -16
- package/lib/AutoFocusMixin.js +5 -12
- package/lib/BeforeInputEventPlugin.js +12 -14
- package/lib/CSSCore.js +6 -13
- package/lib/CSSProperty.js +10 -14
- package/lib/CSSPropertyOperations.js +46 -12
- package/lib/CallbackQueue.js +7 -14
- package/lib/ChangeEventPlugin.js +5 -12
- package/lib/ClientReactRootIndex.js +5 -12
- package/lib/CompositionEventPlugin.js +5 -12
- package/lib/DOMChildrenOperations.js +8 -15
- package/lib/DOMProperty.js +16 -19
- package/lib/DOMPropertyOperations.js +14 -14
- package/lib/Danger.js +12 -17
- package/lib/DefaultEventPluginOrder.js +5 -12
- package/lib/EnterLeaveEventPlugin.js +5 -12
- package/lib/EventConstants.js +5 -12
- package/lib/EventListener.js +14 -0
- package/lib/EventPluginHub.js +8 -26
- package/lib/EventPluginRegistry.js +5 -12
- package/lib/EventPluginUtils.js +5 -12
- package/lib/EventPropagators.js +12 -17
- package/lib/ExecutionEnvironment.js +5 -12
- package/lib/HTMLDOMPropertyConfig.js +16 -15
- package/lib/LinkedStateMixin.js +5 -12
- package/lib/LinkedValueUtils.js +5 -12
- package/lib/LocalEventTrapMixin.js +8 -14
- package/lib/MobileSafariClickEventPlugin.js +5 -12
- package/lib/Object.assign.js +45 -0
- package/lib/PooledClass.js +5 -12
- package/lib/React.js +87 -54
- package/lib/ReactBrowserComponentMixin.js +5 -12
- package/lib/ReactBrowserEventEmitter.js +7 -14
- package/lib/ReactCSSTransitionGroup.js +15 -17
- package/lib/ReactCSSTransitionGroupChild.js +9 -13
- package/lib/ReactChildren.js +5 -12
- package/lib/ReactComponent.js +61 -68
- package/lib/ReactComponentBrowserEnvironment.js +5 -12
- package/lib/ReactComponentWithPureRenderMixin.js +5 -12
- package/lib/ReactCompositeComponent.js +191 -180
- package/lib/ReactContext.js +8 -15
- package/lib/ReactCurrentOwner.js +5 -12
- package/lib/ReactDOM.js +145 -177
- package/lib/ReactDOMButton.js +8 -14
- package/lib/ReactDOMComponent.js +103 -38
- package/lib/ReactDOMForm.js +9 -15
- package/lib/ReactDOMIDOperations.js +5 -12
- package/lib/ReactDOMImg.js +8 -14
- package/lib/ReactDOMInput.js +30 -38
- package/lib/ReactDOMOption.js +8 -14
- package/lib/ReactDOMSelect.js +25 -24
- package/lib/ReactDOMSelection.js +11 -18
- package/lib/ReactDOMTextarea.js +19 -24
- package/lib/ReactDefaultBatchingStrategy.js +14 -18
- package/lib/ReactDefaultInjection.js +23 -26
- package/lib/ReactDefaultPerf.js +14 -17
- package/lib/ReactDefaultPerfAnalysis.js +18 -17
- package/lib/ReactElement.js +242 -0
- package/lib/{ReactDescriptorValidator.js → ReactElementValidator.js} +51 -56
- package/lib/ReactEmptyComponent.js +8 -13
- package/lib/ReactErrorUtils.js +5 -12
- package/lib/ReactEventEmitterMixin.js +5 -12
- package/lib/ReactEventListener.js +7 -14
- package/lib/ReactInjection.js +7 -14
- package/lib/ReactInputSelection.js +5 -12
- package/lib/ReactInstanceHandles.js +5 -12
- package/lib/ReactLegacyElement.js +243 -0
- package/lib/ReactLink.js +5 -12
- package/lib/ReactMarkupChecksum.js +5 -12
- package/lib/ReactMount.js +45 -32
- package/lib/ReactMultiChild.js +14 -18
- package/lib/ReactMultiChildUpdateTypes.js +5 -12
- package/lib/ReactNativeComponent.js +69 -0
- package/lib/ReactOwner.js +5 -12
- package/lib/ReactPerf.js +8 -13
- package/lib/ReactPropTransferer.js +34 -33
- package/lib/ReactPropTypeLocationNames.js +5 -12
- package/lib/ReactPropTypeLocations.js +5 -12
- package/lib/ReactPropTypes.js +38 -29
- package/lib/ReactPutListenerQueue.js +7 -14
- package/lib/ReactReconcileTransaction.js +7 -15
- package/lib/ReactRootIndex.js +5 -12
- package/lib/ReactServerRendering.js +21 -34
- package/lib/ReactServerRenderingTransaction.js +11 -15
- package/lib/ReactStateSetters.js +5 -12
- package/lib/ReactTestUtils.js +31 -33
- package/lib/ReactTextComponent.js +18 -21
- package/lib/ReactTransitionChildMapping.js +6 -13
- package/lib/ReactTransitionEvents.js +5 -12
- package/lib/ReactTransitionGroup.js +14 -17
- package/lib/ReactUpdates.js +43 -22
- package/lib/ReactWithAddons.js +7 -13
- package/lib/SVGDOMPropertyConfig.js +5 -12
- package/lib/SelectEventPlugin.js +13 -20
- package/lib/ServerReactRootIndex.js +5 -12
- package/lib/SimpleEventPlugin.js +20 -15
- package/lib/SyntheticClipboardEvent.js +5 -12
- package/lib/SyntheticCompositionEvent.js +5 -12
- package/lib/SyntheticDragEvent.js +5 -12
- package/lib/SyntheticEvent.js +9 -17
- package/lib/SyntheticFocusEvent.js +5 -12
- package/lib/SyntheticInputEvent.js +4 -11
- package/lib/SyntheticKeyboardEvent.js +17 -19
- package/lib/SyntheticMouseEvent.js +5 -12
- package/lib/SyntheticTouchEvent.js +5 -12
- package/lib/SyntheticUIEvent.js +5 -12
- package/lib/SyntheticWheelEvent.js +5 -12
- package/lib/Transaction.js +5 -12
- package/lib/ViewportMetrics.js +5 -12
- package/lib/accumulateInto.js +62 -0
- package/lib/adler32.js +6 -13
- package/lib/camelize.js +30 -0
- package/lib/camelizeStyleName.js +40 -0
- package/lib/cloneWithProps.js +9 -15
- package/lib/containsNode.js +5 -12
- package/lib/copyProperties.js +12 -12
- package/lib/createArrayFrom.js +5 -12
- package/lib/createFullPageComponent.js +12 -18
- package/lib/createNodesFromMarkup.js +5 -12
- package/lib/cx.js +5 -12
- package/lib/dangerousStyleValue.js +5 -12
- package/lib/deprecated.js +47 -0
- package/lib/emptyFunction.js +11 -22
- package/lib/emptyObject.js +5 -12
- package/lib/escapeTextForBrowser.js +5 -12
- package/lib/flattenChildren.js +19 -13
- package/lib/focusNode.js +10 -16
- package/lib/forEachAccumulated.js +5 -12
- package/lib/getActiveElement.js +5 -12
- package/lib/getEventCharCode.js +50 -0
- package/lib/getEventKey.js +9 -21
- package/lib/getEventModifierState.js +4 -11
- package/lib/getEventTarget.js +5 -12
- package/lib/getMarkupWrap.js +5 -12
- package/lib/getNodeForCharacterOffset.js +5 -12
- package/lib/getReactRootElementInContainer.js +5 -12
- package/lib/getTextContentAccessor.js +5 -12
- package/lib/getUnboundedScrollPosition.js +5 -12
- package/lib/hyphenate.js +5 -12
- package/lib/hyphenateStyleName.js +8 -15
- package/lib/instantiateReactComponent.js +90 -42
- package/lib/invariant.js +5 -12
- package/lib/isEventSupported.js +5 -12
- package/lib/isNode.js +5 -12
- package/lib/isTextInputElement.js +5 -12
- package/lib/isTextNode.js +5 -12
- package/lib/joinClasses.js +8 -13
- package/lib/keyMirror.js +5 -12
- package/lib/keyOf.js +5 -12
- package/lib/mapObject.js +35 -36
- package/lib/memoizeStringOnly.js +5 -12
- package/lib/merge.js +14 -17
- package/lib/mergeInto.js +13 -35
- package/lib/monitorCodeUse.js +5 -12
- package/lib/onlyChild.js +8 -15
- package/lib/performance.js +5 -12
- package/lib/performanceNow.js +5 -12
- package/lib/setInnerHTML.js +10 -19
- package/lib/shallowEqual.js +6 -13
- package/lib/shouldUpdateReactComponent.js +14 -22
- package/lib/toArray.js +5 -12
- package/lib/traverseAllChildren.js +34 -48
- package/lib/update.js +8 -15
- package/lib/warning.js +6 -13
- package/package.json +3 -8
- package/lib/ReactDescriptor.js +0 -251
- package/lib/accumulate.js +0 -54
- package/lib/mergeHelpers.js +0 -147
- package/lib/mixInto.js +0 -34
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactEmptyComponent
|
|
17
10
|
*/
|
|
18
11
|
|
|
19
12
|
"use strict";
|
|
20
13
|
|
|
14
|
+
var ReactElement = require("./ReactElement");
|
|
15
|
+
|
|
21
16
|
var invariant = require("./invariant");
|
|
22
17
|
|
|
23
18
|
var component;
|
|
@@ -27,7 +22,7 @@ var nullComponentIdsRegistry = {};
|
|
|
27
22
|
|
|
28
23
|
var ReactEmptyComponentInjection = {
|
|
29
24
|
injectEmptyComponent: function(emptyComponent) {
|
|
30
|
-
component = emptyComponent;
|
|
25
|
+
component = ReactElement.createFactory(emptyComponent);
|
|
31
26
|
}
|
|
32
27
|
};
|
|
33
28
|
|
package/lib/ReactErrorUtils.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactErrorUtils
|
|
17
10
|
* @typechecks
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactEventEmitterMixin
|
|
17
10
|
*/
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactEventListener
|
|
17
10
|
* @typechecks static-only
|
|
@@ -26,9 +19,9 @@ var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
|
26
19
|
var ReactMount = require("./ReactMount");
|
|
27
20
|
var ReactUpdates = require("./ReactUpdates");
|
|
28
21
|
|
|
22
|
+
var assign = require("./Object.assign");
|
|
29
23
|
var getEventTarget = require("./getEventTarget");
|
|
30
24
|
var getUnboundedScrollPosition = require("./getUnboundedScrollPosition");
|
|
31
|
-
var mixInto = require("./mixInto");
|
|
32
25
|
|
|
33
26
|
/**
|
|
34
27
|
* Finds the parent React component of `node`.
|
|
@@ -54,7 +47,7 @@ function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
|
|
|
54
47
|
this.nativeEvent = nativeEvent;
|
|
55
48
|
this.ancestors = [];
|
|
56
49
|
}
|
|
57
|
-
|
|
50
|
+
assign(TopLevelCallbackBookKeeping.prototype, {
|
|
58
51
|
destructor: function() {
|
|
59
52
|
this.topLevelType = null;
|
|
60
53
|
this.nativeEvent = null;
|
package/lib/ReactInjection.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactInjection
|
|
17
10
|
*/
|
|
@@ -22,9 +15,9 @@ var DOMProperty = require("./DOMProperty");
|
|
|
22
15
|
var EventPluginHub = require("./EventPluginHub");
|
|
23
16
|
var ReactComponent = require("./ReactComponent");
|
|
24
17
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
25
|
-
var ReactDOM = require("./ReactDOM");
|
|
26
18
|
var ReactEmptyComponent = require("./ReactEmptyComponent");
|
|
27
19
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
20
|
+
var ReactNativeComponent = require("./ReactNativeComponent");
|
|
28
21
|
var ReactPerf = require("./ReactPerf");
|
|
29
22
|
var ReactRootIndex = require("./ReactRootIndex");
|
|
30
23
|
var ReactUpdates = require("./ReactUpdates");
|
|
@@ -35,8 +28,8 @@ var ReactInjection = {
|
|
|
35
28
|
DOMProperty: DOMProperty.injection,
|
|
36
29
|
EmptyComponent: ReactEmptyComponent.injection,
|
|
37
30
|
EventPluginHub: EventPluginHub.injection,
|
|
38
|
-
DOM: ReactDOM.injection,
|
|
39
31
|
EventEmitter: ReactBrowserEventEmitter.injection,
|
|
32
|
+
NativeComponent: ReactNativeComponent.injection,
|
|
40
33
|
Perf: ReactPerf.injection,
|
|
41
34
|
RootIndex: ReactRootIndex.injection,
|
|
42
35
|
Updates: ReactUpdates.injection
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactInputSelection
|
|
17
10
|
*/
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-2014 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
15
8
|
*
|
|
16
9
|
* @providesModule ReactInstanceHandles
|
|
17
10
|
* @typechecks static-only
|
|
@@ -0,0 +1,243 @@
|
|
|
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;
|