Lightpanda: the headless browser designed for AI and automation
selector: match nothing for an empty ^=, $= or *= value
Jay Hemnanib3b19b6ebe37
diff --git a/src/browser/tests/document/query_selector_attributes.html b/src/browser/tests/document/query_selector_attributes.htmlindex 7caad780d..e5085a545 100644--- a/src/browser/tests/document/query_selector_attributes.html+++ b/src/browser/tests/document/query_selector_attributes.html@@ -93,6 +93,14 @@testing.expectEqual('Link 1', exampleLink.innerText);</script>+<script id="empty_value">+ // An empty value for ^=, $= and *= matches nothing+ testing.expectEqual(0, document.querySelectorAll('[href^=""]').length);+ testing.expectEqual(0, document.querySelectorAll('[href$=""]').length);+ testing.expectEqual(0, document.querySelectorAll('[href*=""]').length);+ testing.expectEqual(0, document.querySelectorAll('[href^="" i]').length);+</script>+<script id="compound">testing.expectEqual(1, document.querySelectorAll('input[type="text"]').length);testing.expectEqual(1, document.querySelectorAll('input[type="password"]').length);diff --git a/src/browser/webapi/selector/List.zig b/src/browser/webapi/selector/List.zigindex 44f5abb37..74e027046 100644--- a/src/browser/webapi/selector/List.zig+++ b/src/browser/webapi/selector/List.zig@@ -500,18 +500,21 @@ fn matchesAttribute(el: *Node.Element, attr: Selector.Attribute) bool {std.mem.eql(u8, value, expected);},.substring => |expected| {+ if (expected.len == 0) return false;return if (case_insensitive)std.ascii.findIgnoreCase(value, expected) != nullelsestd.mem.find(u8, value, expected) != null;},.starts_with => |expected| {+ if (expected.len == 0) return false;return if (case_insensitive)std.ascii.startsWithIgnoreCase(value, expected)elsestd.mem.startsWith(u8, value, expected);},.ends_with => |expected| {+ if (expected.len == 0) return false;return if (case_insensitive)std.ascii.endsWithIgnoreCase(value, expected)else