File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,12 @@ export function initDebug() {
140
140
} ;
141
141
142
142
options . vnode = ( vnode ) => {
143
+ let source ;
144
+ if ( vnode . props && vnode . props . __source ) {
145
+ source = vnode . props . __source ;
146
+ delete vnode . props . __source ;
147
+ }
148
+ vnode . __source = source ;
143
149
Object . defineProperties ( vnode , deprecatedAttributes ) ;
144
150
if ( oldVnode ) oldVnode ( vnode ) ;
145
151
} ;
Original file line number Diff line number Diff line change @@ -82,6 +82,20 @@ describe('debug', () => {
82
82
expect ( fn ) . to . throw ( / c r e a t e E l e m e n t / ) ;
83
83
} ) ;
84
84
85
+ it ( 'should add __source to the vnode in debug mode.' , ( ) => {
86
+ const vnode = h ( 'div' , {
87
+ __source : {
88
+ fileName : 'div.jsx' ,
89
+ lineNumber : 3
90
+ }
91
+ } ) ;
92
+ expect ( vnode . __source ) . to . deep . equal ( {
93
+ fileName : 'div.jsx' ,
94
+ lineNumber : 3
95
+ } ) ;
96
+ expect ( vnode . props . __source ) . to . be . undefined ;
97
+ } ) ;
98
+
85
99
it ( 'should throw an error when using a hook outside a render' , ( ) => {
86
100
class App extends Component {
87
101
componentWillMount ( ) {
You can’t perform that action at this time.
0 commit comments