From eef717ced7a06836928f0d9a0e3ed0093b1c6d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Wed, 10 Sep 2014 23:14:27 -0700 Subject: [PATCH] Add createElement for 0.11 This also adds the deprecation notice to createDescriptor. Chances are that nobody is using that, but doesn't hurt. --- src/browser/ui/React.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/browser/ui/React.js b/src/browser/ui/React.js index 100c6bc2021..cbdc8fbd3c1 100644 --- a/src/browser/ui/React.js +++ b/src/browser/ui/React.js @@ -38,9 +38,21 @@ var ReactServerRendering = require('ReactServerRendering'); var ReactTextComponent = require('ReactTextComponent'); var onlyChild = require('onlyChild'); +var warning = require('warning'); ReactDefaultInjection.inject(); +// Specifying arguments isn't necessary since we just use apply anyway, but it +// makes it clear for those actually consuming this API. +function createDescriptor(type, props, children) { + var args = Array.prototype.slice.call(arguments, 1); + return type.apply(null, args); +} + +if (__DEV__) { + var _warnedForDeprecation = false; +} + var React = { Children: { map: ReactChildren.map, @@ -54,10 +66,18 @@ var React = { EventPluginUtils.useTouchEvents = shouldUseTouch; }, createClass: ReactCompositeComponent.createClass, - createDescriptor: function(type, props, children) { - var args = Array.prototype.slice.call(arguments, 1); - return type.apply(null, args); + createDescriptor: function() { + if (__DEV__) { + warning( + _warnedForDeprecation, + 'React.createDescriptor is deprecated and will be removed in the ' + + 'next version of React. Use React.createElement instead.' + ); + _warnedForDeprecation = true; + } + return createDescriptor.apply(this, arguments); }, + createElement: createDescriptor, constructAndRenderComponent: ReactMount.constructAndRenderComponent, constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID, renderComponent: ReactPerf.measure(