File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -45,17 +45,20 @@ function visitNodeFollowingNgInjectComment(node, ctx) {
45
45
46
46
47
47
function addRemoveInjectsArray ( params , posAfterFunctionDeclaration , name ) {
48
- const str1 = fmt ( "{0}.$injects" , name ) ;
49
- const str2 = fmt ( " = {0};" , ctx . stringify ( params , ctx . quot ) ) ;
50
- const str = "\n" + str1 + str2 ;
48
+ const str = fmt ( "\n{0}.$injects = {1};" , name , ctx . stringify ( params , ctx . quot ) ) ;
51
49
52
50
ctx . triggers . add ( {
53
51
pos : posAfterFunctionDeclaration ,
54
52
fn : visitNodeFollowingFunctionDeclaration ,
55
53
} ) ;
56
54
57
55
function visitNodeFollowingFunctionDeclaration ( nextNode ) {
58
- const hasInjectsArray = ( str1 === ctx . src . slice ( nextNode . range [ 0 ] , nextNode . range [ 0 ] + str1 . length ) ) ;
56
+ const assignment = nextNode . expression ;
57
+ let lvalue ;
58
+ const hasInjectsArray = ( nextNode . type === "ExpressionStatement" && assignment . type === "AssignmentExpression" &&
59
+ assignment . operator === "=" &&
60
+ ( lvalue = assignment . left ) . type === "MemberExpression" &&
61
+ lvalue . computed === false && lvalue . object . name === name && lvalue . property . name === "$injects" ) ;
59
62
60
63
if ( ctx . mode === "rebuild" && hasInjectsArray ) {
61
64
ctx . fragments . push ( {
You can’t perform that action at this time.
0 commit comments