Skip to content

Commit 7142e9e

Browse files
committed
Don't stop matching subtree at its root
1 parent 7558e2e commit 7142e9e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/select.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ select.rule = function (selector, ast) {
4040
function walk (node, parent) {
4141
if (node.type == selector.tagName) {
4242
if (!selector.rule) {
43-
return append(result, [node]);
43+
append(result, [node]);
4444
}
45-
46-
if (!selector.rule.nestingOperator || selector.rule.nestingOperator == '>') {
45+
else if (!selector.rule.nestingOperator ||
46+
selector.rule.nestingOperator == '>') {
4747
if (!node.children) return;
4848
node.children.forEach(function (childNode) {
4949
[].push.apply(result, select.rule(selector.rule, childNode));

test/test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ test('type selector', function (t) {
2121
t.equal(select(ast, 'text')[1], ast.children[1].children[0]);
2222
t.equal(select(ast, 'tableRow').length, 2);
2323
t.equal(select(ast, 'heading').length, 5);
24+
25+
t.deepEqual(select(ast, 'list'), [
26+
path(ast, [4]),
27+
path(ast, [4, 1, 1]),
28+
path(ast, [4, 1, 1, 0, 1]),
29+
path(ast, [6])
30+
]);
31+
2432
t.end();
2533
});
2634

0 commit comments

Comments
 (0)