diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index 31054bd5efc92..3e789d33b14ac 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -29,7 +29,6 @@ var ReactDOMButton = require('ReactDOMButton'); var ReactDOMComponentFlags = require('ReactDOMComponentFlags'); var ReactDOMComponentTree = require('ReactDOMComponentTree'); var ReactDOMInput = require('ReactDOMInput'); -var ReactDOMInstrumentation = require('ReactDOMInstrumentation'); var ReactDOMOption = require('ReactDOMOption'); var ReactDOMSelect = require('ReactDOMSelect'); var ReactDOMTextarea = require('ReactDOMTextarea'); @@ -652,9 +651,6 @@ ReactDOMComponent.Mixin = { markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue); } } else { - if (__DEV__) { - ReactDOMInstrumentation.debugTool.onCreateMarkupForProperty(propKey, propValue, this._currentElement); - } markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue); } if (markup) { diff --git a/src/renderers/dom/shared/ReactDOMDebugTool.js b/src/renderers/dom/shared/ReactDOMDebugTool.js index 2b8c8c28ab4d0..ac7bb10d6dab4 100644 --- a/src/renderers/dom/shared/ReactDOMDebugTool.js +++ b/src/renderers/dom/shared/ReactDOMDebugTool.js @@ -50,8 +50,8 @@ var ReactDOMDebugTool = { } } }, - onCreateMarkupForProperty(name, value, element) { - emitEvent('onCreateMarkupForProperty', name, value, element); + onCreateMarkupForProperty(name, value) { + emitEvent('onCreateMarkupForProperty', name, value); }, onSetValueForProperty(node, name, value) { emitEvent('onSetValueForProperty', node, name, value); @@ -59,6 +59,9 @@ var ReactDOMDebugTool = { onDeleteValueForProperty(node, name) { emitEvent('onDeleteValueForProperty', node, name); }, + onInstantiateReactComponent(instance) { + emitEvent('onInstantiateReactComponent', instance); + }, }; ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyDevtool); diff --git a/src/renderers/dom/shared/devtools/ReactDOMUnknownPropertyDevtool.js b/src/renderers/dom/shared/devtools/ReactDOMUnknownPropertyDevtool.js index d0670a71eb5ee..cb613436cfee2 100644 --- a/src/renderers/dom/shared/devtools/ReactDOMUnknownPropertyDevtool.js +++ b/src/renderers/dom/shared/devtools/ReactDOMUnknownPropertyDevtool.js @@ -13,11 +13,11 @@ var DOMProperty = require('DOMProperty'); var EventPluginRegistry = require('EventPluginRegistry'); -var ReactDOMComponentTree = require('ReactDOMComponentTree'); var warning = require('warning'); if (__DEV__) { + var cachedSource; var reactProps = { children: true, dangerouslySetInnerHTML: true, @@ -80,28 +80,19 @@ if (__DEV__) { } var ReactDOMUnknownPropertyDevtool = { - onCreateMarkupForProperty(name, value, element) { - warnUnknownProperty(name, getSourceFromElement(element)); + onCreateMarkupForProperty(name, value) { + warnUnknownProperty(name, cachedSource); }, onSetValueForProperty(node, name, value) { - warnUnknownProperty(name, getSourceFromNode(node)); + warnUnknownProperty(name, cachedSource); }, onDeleteValueForProperty(node, name) { - warnUnknownProperty(name, getSourceFromNode(node)); + warnUnknownProperty(name, cachedSource); + }, + onInstantiateReactComponent(instance) { + //Get JSX _source for use in warnings + cachedSource = instance._currentElement ? instance._currentElement._source : null; }, -}; - -var getSourceFromNode = function(node) { - var instance = ReactDOMComponentTree.getInstanceFromNode(node); - if (instance) { - return getSourceFromElement(instance._currentElement); - } -}; - -var getSourceFromElement = function(element) { - if (element) { - return element._source; - } }; module.exports = ReactDOMUnknownPropertyDevtool; diff --git a/src/renderers/shared/reconciler/instantiateReactComponent.js b/src/renderers/shared/reconciler/instantiateReactComponent.js index cb0208f92a68f..322f13295c2b2 100644 --- a/src/renderers/shared/reconciler/instantiateReactComponent.js +++ b/src/renderers/shared/reconciler/instantiateReactComponent.js @@ -12,6 +12,7 @@ 'use strict'; var ReactCompositeComponent = require('ReactCompositeComponent'); +var ReactDOMInstrumentation = require('ReactDOMInstrumentation'); var ReactEmptyComponent = require('ReactEmptyComponent'); var ReactNativeComponent = require('ReactNativeComponent'); @@ -130,6 +131,10 @@ function instantiateReactComponent(node) { } } + if (__DEV__) { + ReactDOMInstrumentation.debugTool.onInstantiateReactComponent(instance); + } + return instance; }