File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -61,10 +61,10 @@ class Container extends Node {
6161 }
6262
6363 // allow users to pass a constructor, or node type string; eg. Word.
64- type = type . name && type . prototype ? type . name : type ;
64+ const isTypeCallable = typeof type === 'function' ;
6565
6666 return this . walk ( ( node , index ) => {
67- if ( node . type === type ) {
67+ if ( isTypeCallable && node instanceof type || ! isTypeCallable && node . type === type ) {
6868 return callback . call ( this , node , index ) ;
6969 }
7070 } ) ;
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ describe('Parser → API', () => {
7171 it ( 'should walk a type constructor' , ( ) => {
7272 let source = '/*1*/ 5px /* 2 */' ,
7373 ast = new Parser ( source ) . parse ( ) ,
74- expected = [ '1' , '2 ' ] ,
74+ expected = [ '1' , ' 2 ' ] ,
7575 index = 0 ;
7676
7777 expect ( ast . first . walkComments ) . to . exist ;
You can’t perform that action at this time.
0 commit comments