@@ -27,7 +27,11 @@ var checkReactTypeSpec = require('checkReactTypeSpec');
2727var canDefineProperty = require ( 'canDefineProperty' ) ;
2828var getComponentName = require ( 'getComponentName' ) ;
2929var getIteratorFn = require ( 'getIteratorFn' ) ;
30- var warning = require ( 'warning' ) ;
30+
31+ if ( __DEV__ ) {
32+ var warning = require ( 'warning' ) ;
33+ var ReactDebugCurrentFrame = require ( 'ReactDebugCurrentFrame' ) ;
34+ }
3135
3236function getDeclarationErrorAddendum ( ) {
3337 if ( ReactCurrentOwner . current ) {
@@ -181,9 +185,7 @@ function validatePropTypes(element) {
181185 componentClass . propTypes ,
182186 element . props ,
183187 'prop' ,
184- name ,
185- element ,
186- null
188+ name
187189 ) ;
188190 }
189191 if ( typeof componentClass . getDefaultProps === 'function' ) {
@@ -248,6 +250,10 @@ var ReactElementValidator = {
248250 return element ;
249251 }
250252
253+ if ( __DEV__ ) {
254+ ReactDebugCurrentFrame . element = element ;
255+ }
256+
251257 // Skip key warning if the type isn't valid since our key validation logic
252258 // doesn't expect a non-string/function type and can throw confusing errors.
253259 // We don't want exception behavior to differ between dev and prod.
@@ -261,6 +267,10 @@ var ReactElementValidator = {
261267
262268 validatePropTypes ( element ) ;
263269
270+ if ( __DEV__ ) {
271+ ReactDebugCurrentFrame . element = null ;
272+ }
273+
264274 return element ;
265275 } ,
266276
@@ -301,10 +311,16 @@ var ReactElementValidator = {
301311
302312 cloneElement : function ( element , props , children ) {
303313 var newElement = ReactElement . cloneElement . apply ( this , arguments ) ;
314+ if ( __DEV__ ) {
315+ ReactDebugCurrentFrame . element = newElement ;
316+ }
304317 for ( var i = 2 ; i < arguments . length ; i ++ ) {
305318 validateChildKeys ( arguments [ i ] , newElement . type ) ;
306319 }
307320 validatePropTypes ( newElement ) ;
321+ if ( __DEV__ ) {
322+ ReactDebugCurrentFrame . element = null ;
323+ }
308324 return newElement ;
309325 } ,
310326
0 commit comments