Skip to content

Commit b45eebd

Browse files
jonathantnealshellscape
authored andcommitted
Fix walk proxies (shellscape#54)
1 parent 4efb347 commit b45eebd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/container.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
});

test/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)