@@ -48,23 +48,25 @@ module.exports = {
4848 // --------------------------------------------------------------------------
4949 // Public
5050 // --------------------------------------------------------------------------
51- let inConstructor = false ;
52- let inCallExpression = false ;
53-
5451 return {
5552 MethodDefinition ( node ) {
5653 if ( node . kind === 'constructor' ) {
57- inConstructor = true ;
54+ components . set ( node , {
55+ inConstructor : true
56+ } ) ;
5857 }
5958 } ,
6059
61- CallExpression : function ( ) {
62- inCallExpression = true ;
60+ CallExpression : function ( node ) {
61+ components . set ( node , {
62+ inCallExpression : true
63+ } ) ;
6364 } ,
6465
6566 AssignmentExpression ( node ) {
6667 let item ;
67- if ( ( inConstructor && ! inCallExpression ) || ! node . left || ! node . left . object ) {
68+ const component = components . get ( utils . getParentComponent ( ) ) ;
69+ if ( ! component || ( component . inConstructor && ! component . inCallExpression ) || ! node . left || ! node . left . object ) {
6870 return ;
6971 }
7072 item = node . left ;
@@ -75,7 +77,6 @@ module.exports = {
7577 item . object . type === 'ThisExpression' &&
7678 item . property . name === 'state'
7779 ) {
78- const component = components . get ( utils . getParentComponent ( ) ) ;
7980 const mutations = ( component && component . mutations ) || [ ] ;
8081 mutations . push ( node . left . object ) ;
8182 components . set ( node , {
@@ -85,13 +86,17 @@ module.exports = {
8586 }
8687 } ,
8788
88- 'CallExpression:exit' : function ( ) {
89- inCallExpression = false ;
89+ 'CallExpression:exit' : function ( node ) {
90+ components . set ( node , {
91+ inCallExpression : false
92+ } ) ;
9093 } ,
9194
9295 'MethodDefinition:exit' : function ( node ) {
9396 if ( node . kind === 'constructor' ) {
94- inConstructor = false ;
97+ components . set ( node , {
98+ inConstructor : false
99+ } ) ;
95100 }
96101 } ,
97102
0 commit comments