File tree 2 files changed +3
-3
lines changed
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 {
61
61
}
62
62
63
63
// 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' ;
65
65
66
66
return this . walk ( ( node , index ) => {
67
- if ( node . type === type ) {
67
+ if ( isTypeCallable && node instanceof type || ! isTypeCallable && node . type === type ) {
68
68
return callback . call ( this , node , index ) ;
69
69
}
70
70
} ) ;
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ describe('Parser → API', () => {
71
71
it ( 'should walk a type constructor' , ( ) => {
72
72
let source = '/*1*/ 5px /* 2 */' ,
73
73
ast = new Parser ( source ) . parse ( ) ,
74
- expected = [ '1' , '2 ' ] ,
74
+ expected = [ '1' , ' 2 ' ] ,
75
75
index = 0 ;
76
76
77
77
expect ( ast . first . walkComments ) . to . exist ;
You can’t perform that action at this time.
0 commit comments