File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,6 +77,21 @@ class StackedSetMap {
7777 return this . defaultValue ;
7878 }
7979
80+ _compress ( ) {
81+ this . map = new Map ( ) ;
82+ for ( const data of this . stack ) {
83+ for ( const pair of data ) {
84+ this . map . set ( pair [ 0 ] , pair [ 1 ] ) ;
85+ }
86+ }
87+ this . stack = [ this . map ] ;
88+ }
89+
90+ asSet ( ) {
91+ this . _compress ( ) ;
92+ return new Set ( Array . from ( this . map . entries ( ) ) . filter ( pair => pair [ 1 ] ) . map ( pair => pair [ 0 ] ) ) ;
93+ }
94+
8095 createChild ( ) {
8196 return new StackedSetMap ( this . defaultValue , this . stack ) ;
8297 }
@@ -1493,7 +1508,7 @@ class Parser extends Tapable {
14931508 if ( expr . type === "Identifier" ) {
14941509 free = ! this . scope . definitions . has ( expr . name ) ;
14951510 exprName . push ( this . scope . renames . get ( expr . name ) || expr . name ) ;
1496- } else if ( expr . type === "ThisExpression" && this . scope . renames . $ this) {
1511+ } else if ( expr . type === "ThisExpression" && this . scope . renames . get ( " this" ) ) {
14971512 free = true ;
14981513 exprName . push ( this . scope . renames . get ( "this" ) ) ;
14991514 } else if ( expr . type === "ThisExpression" ) {
Original file line number Diff line number Diff line change @@ -219,7 +219,7 @@ describe("Parser", () => {
219219 } ) ;
220220 testParser . plugin ( "expression fgh" , ( expr ) => {
221221 if ( ! testParser . state . fgh ) testParser . state . fgh = [ ] ;
222- testParser . state . fgh . push ( testParser . scope . definitions . join ( " " ) ) ;
222+ testParser . state . fgh . push ( Array . from ( testParser . scope . definitions . asSet ( ) ) . join ( " " ) ) ;
223223 return true ;
224224 } ) ;
225225 testParser . plugin ( "expression fgh.sub" , ( expr ) => {
You can’t perform that action at this time.
0 commit comments