Skip to content

Commit

Permalink
New approach to fix for #6062
Browse files Browse the repository at this point in the history
  • Loading branch information
troydemonbreun committed Apr 4, 2016
1 parent 295b048 commit fb2910f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
4 changes: 0 additions & 4 deletions src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions src/renderers/dom/shared/ReactDOMDebugTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ 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);
},
onDeleteValueForProperty(node, name) {
emitEvent('onDeleteValueForProperty', node, name);
},
onInstantiateReactComponent(instance) {
emitEvent('onInstantiateReactComponent', instance);
},
};

ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyDevtool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
5 changes: 5 additions & 0 deletions src/renderers/shared/reconciler/instantiateReactComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'use strict';

var ReactCompositeComponent = require('ReactCompositeComponent');
var ReactDOMInstrumentation = require('ReactDOMInstrumentation');
var ReactEmptyComponent = require('ReactEmptyComponent');
var ReactNativeComponent = require('ReactNativeComponent');

Expand Down Expand Up @@ -130,6 +131,10 @@ function instantiateReactComponent(node) {
}
}

if (__DEV__) {
ReactDOMInstrumentation.debugTool.onInstantiateReactComponent(instance);
}

return instance;
}

Expand Down

0 comments on commit fb2910f

Please sign in to comment.