Merge pull request #1749 from lightpanda-io/empty_is_and_where_pseudoselector

Empty :is() and :where() pseudoselectors are valid (and return nothing)
This commit is contained in:
Karl Seguin authored and GitHub committed 2026-03-09 16:55:43 +08:00
commit 034b089433
3 files changed
+13 -4

No files matched your search

@@ -81,6 +81,17 @@
}
</script>
<script id="is_empty">
{
// Empty :is() and :where() are valid per spec and match nothing
const isEmptyResult = document.querySelectorAll(':is()');
testing.expectEqual(0, isEmptyResult.length);
const whereEmptyResult = document.querySelectorAll(':where()');
testing.expectEqual(0, whereEmptyResult.length);
}
</script>
<div id=escaped class=":popover-open"></div>
<script id="escaped">
{
@@ -12,8 +12,6 @@
// Empty functional pseudo-classes should error
testing.expectError("Error: InvalidPseudoClass", () => container.querySelector(':has()'));
testing.expectError("Error: InvalidPseudoClass", () => container.querySelector(':not()'));
testing.expectError("Error: InvalidPseudoClass", () => container.querySelector(':is()'));
testing.expectError("Error: InvalidPseudoClass", () => container.querySelector(':where()'));
testing.expectError("Error: InvalidPseudoClass", () => container.querySelector(':lang()'));
}
</script>
+2 -2
View File
@@ -487,7 +487,7 @@ fn pseudoClass(self: *Parser, arena: Allocator, page: *Page) !Selector.PseudoCla
if (self.peek() != ')') return error.InvalidPseudoClass;
self.input = self.input[1..];
if (selectors.items.len == 0) return error.InvalidPseudoClass;
// Empty :is() is valid per spec - matches nothing
return .{ .is = selectors.items };
}
@@ -514,7 +514,7 @@ fn pseudoClass(self: *Parser, arena: Allocator, page: *Page) !Selector.PseudoCla
if (self.peek() != ')') return error.InvalidPseudoClass;
self.input = self.input[1..];
if (selectors.items.len == 0) return error.InvalidPseudoClass;
// Empty :where() is valid per spec - matches nothing
return .{ .where = selectors.items };
}