@@ -48,23 +48,25 @@ module.exports = {
48
48
// --------------------------------------------------------------------------
49
49
// Public
50
50
// --------------------------------------------------------------------------
51
- let inConstructor = false ;
52
- let inCallExpression = false ;
53
-
54
51
return {
55
52
MethodDefinition ( node ) {
56
53
if ( node . kind === 'constructor' ) {
57
- inConstructor = true ;
54
+ components . set ( node , {
55
+ inConstructor : true
56
+ } ) ;
58
57
}
59
58
} ,
60
59
61
- CallExpression : function ( ) {
62
- inCallExpression = true ;
60
+ CallExpression : function ( node ) {
61
+ components . set ( node , {
62
+ inCallExpression : true
63
+ } ) ;
63
64
} ,
64
65
65
66
AssignmentExpression ( node ) {
66
67
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 ) {
68
70
return ;
69
71
}
70
72
item = node . left ;
@@ -75,7 +77,6 @@ module.exports = {
75
77
item . object . type === 'ThisExpression' &&
76
78
item . property . name === 'state'
77
79
) {
78
- const component = components . get ( utils . getParentComponent ( ) ) ;
79
80
const mutations = ( component && component . mutations ) || [ ] ;
80
81
mutations . push ( node . left . object ) ;
81
82
components . set ( node , {
@@ -85,13 +86,17 @@ module.exports = {
85
86
}
86
87
} ,
87
88
88
- 'CallExpression:exit' : function ( ) {
89
- inCallExpression = false ;
89
+ 'CallExpression:exit' : function ( node ) {
90
+ components . set ( node , {
91
+ inCallExpression : false
92
+ } ) ;
90
93
} ,
91
94
92
95
'MethodDefinition:exit' : function ( node ) {
93
96
if ( node . kind === 'constructor' ) {
94
- inConstructor = false ;
97
+ components . set ( node , {
98
+ inConstructor : false
99
+ } ) ;
95
100
}
96
101
} ,
97
102
0 commit comments