File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1047,6 +1047,14 @@ class Parser extends Tapable {
10471047 }
10481048
10491049 walkNewExpression ( expression ) {
1050+ const callee = this . evaluateExpression ( expression . callee ) ;
1051+ if ( callee . isIdentifier ( ) ) {
1052+ const result = this . applyPluginsBailResult ( "new " + callee . identifier , expression ) ;
1053+ if ( result === true ) {
1054+ return ;
1055+ }
1056+ }
1057+
10501058 this . walkExpression ( expression . callee ) ;
10511059 if ( expression . arguments )
10521060 this . walkExpressions ( expression . arguments ) ;
Original file line number Diff line number Diff line change @@ -191,6 +191,13 @@ describe("Parser", () => {
191191 ijksub : [ "test" ]
192192 }
193193 ] ,
194+ "new Foo(...)" : [
195+ function ( ) {
196+ new xyz ( "membertest" ) ;
197+ } , {
198+ xyz : [ "membertest" ]
199+ }
200+ ] ,
194201 } ;
195202
196203 Object . keys ( testCases ) . forEach ( ( name ) => {
@@ -237,6 +244,11 @@ describe("Parser", () => {
237244 testParser . state . expressions . push ( expr . name ) ;
238245 return true ;
239246 } ) ;
247+ testParser . plugin ( "new xyz" , ( expr ) => {
248+ if ( ! testParser . state . xyz ) testParser . state . xyz = [ ] ;
249+ testParser . state . xyz . push ( testParser . parseString ( expr . arguments [ 0 ] ) ) ;
250+ return true ;
251+ } ) ;
240252 const actual = testParser . parse ( source ) ;
241253 should . strictEqual ( typeof actual , "object" ) ;
242254 actual . should . be . eql ( state ) ;
You can’t perform that action at this time.
0 commit comments