From b04acc625aae383a72ab84da99dc32a751ea818d Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Fri, 1 Jul 2016 19:16:00 -0700 Subject: [PATCH] Cut out isomorphic dependencies from the renderers These files reaches into isomorphic files. The ReactElement functions are exposed on the React object anyway so I can just use those instead. I also found some files that are not shared that should be in renderers shared. --- grunt/config/browserify.js | 1 + src/renderers/dom/client/ReactMount.js | 16 ++++--------- .../reconciler/ReactCompositeComponent.js | 24 +++++++++++-------- .../stack/reconciler}/ReactNodeTypes.js | 0 .../shared/stack/reconciler/ReactUpdates.js | 2 +- .../getHostComponentFromComposite.js | 0 6 files changed, 21 insertions(+), 22 deletions(-) rename src/{shared/utils => renderers/shared/stack/reconciler}/ReactNodeTypes.js (100%) rename src/{shared/utils => renderers/shared/stack/reconciler}/getHostComponentFromComposite.js (100%) diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index 1a7f087e94dea..a5c518ee0c7b1 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -19,6 +19,7 @@ var SECRET_DOM_INTERNALS_NAME = 'ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_W var shimSharedModules = globalShim.configure({ './ReactCurrentOwner': SECRET_INTERNALS_NAME + '.ReactCurrentOwner', './ReactComponentTreeDevtool': SECRET_INTERNALS_NAME + '.ReactComponentTreeDevtool', + './ReactElement': 'React', // All the methods that are shared are exposed. }); // Shim references to ReactDOM internals from addons. diff --git a/src/renderers/dom/client/ReactMount.js b/src/renderers/dom/client/ReactMount.js index d7fb1b561f835..59c80508bb795 100644 --- a/src/renderers/dom/client/ReactMount.js +++ b/src/renderers/dom/client/ReactMount.js @@ -100,7 +100,7 @@ function mountComponentIntoNode( ) { var markerName; if (ReactFeatureFlags.logTopLevelRenders) { - var wrappedElement = wrapperInstance._currentElement.props; + var wrappedElement = wrapperInstance._currentElement.props.child; var type = wrappedElement.type; markerName = 'React mount: ' + ( typeof type === 'string' ? type : @@ -235,8 +235,7 @@ if (__DEV__) { TopLevelWrapper.displayName = 'TopLevelWrapper'; } TopLevelWrapper.prototype.render = function() { - // this.props is actually a ReactElement - return this.props; + return this.props.child; }; /** @@ -432,14 +431,9 @@ var ReactMount = { 'for your app.' ); - var nextWrappedElement = ReactElement( + var nextWrappedElement = ReactElement.createElement( TopLevelWrapper, - null, - null, - null, - null, - null, - nextElement + { child: nextElement } ); var nextContext; @@ -454,7 +448,7 @@ var ReactMount = { if (prevComponent) { var prevWrappedElement = prevComponent._currentElement; - var prevElement = prevWrappedElement.props; + var prevElement = prevWrappedElement.props.child; if (shouldUpdateReactComponent(prevElement, nextElement)) { var publicInst = prevComponent._renderedComponent.getPublicInstance(); var updatedCallback = callback && function() { diff --git a/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js b/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js index d12995062a724..ad144446bc0ad 100644 --- a/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js +++ b/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js @@ -18,11 +18,13 @@ var ReactErrorUtils = require('ReactErrorUtils'); var ReactInstanceMap = require('ReactInstanceMap'); var ReactInstrumentation = require('ReactInstrumentation'); var ReactNodeTypes = require('ReactNodeTypes'); -var ReactPropTypeLocations = require('ReactPropTypeLocations'); var ReactReconciler = require('ReactReconciler'); var ReactUpdateQueue = require('ReactUpdateQueue'); -var checkReactTypeSpec = require('checkReactTypeSpec'); +if (__DEV__) { + var ReactPropTypeLocations = require('ReactPropTypeLocations'); + var checkReactTypeSpec = require('checkReactTypeSpec'); +} var emptyObject = require('emptyObject'); var invariant = require('invariant'); @@ -677,14 +679,16 @@ var ReactCompositeComponentMixin = { * @private */ _checkContextTypes: function(typeSpecs, values, location) { - checkReactTypeSpec( - typeSpecs, - values, - location, - this.getName(), - null, - this._debugID - ); + if (__DEV__) { + checkReactTypeSpec( + typeSpecs, + values, + location, + this.getName(), + null, + this._debugID + ); + } }, receiveComponent: function(nextElement, transaction, nextContext) { diff --git a/src/shared/utils/ReactNodeTypes.js b/src/renderers/shared/stack/reconciler/ReactNodeTypes.js similarity index 100% rename from src/shared/utils/ReactNodeTypes.js rename to src/renderers/shared/stack/reconciler/ReactNodeTypes.js diff --git a/src/renderers/shared/stack/reconciler/ReactUpdates.js b/src/renderers/shared/stack/reconciler/ReactUpdates.js index cdeb784b316d5..956100b4dac82 100644 --- a/src/renderers/shared/stack/reconciler/ReactUpdates.js +++ b/src/renderers/shared/stack/reconciler/ReactUpdates.js @@ -162,7 +162,7 @@ function runBatchedUpdates(transaction) { var namedComponent = component; // Duck type TopLevelWrapper. This is probably always true. if ( - component._currentElement.props === + component._currentElement.props.child === component._renderedComponent._currentElement ) { namedComponent = component._renderedComponent; diff --git a/src/shared/utils/getHostComponentFromComposite.js b/src/renderers/shared/stack/reconciler/getHostComponentFromComposite.js similarity index 100% rename from src/shared/utils/getHostComponentFromComposite.js rename to src/renderers/shared/stack/reconciler/getHostComponentFromComposite.js