Skip to content

[a^=""], [a$=""] and [a~=""] match elements #341

Closed

Description

@robertmorelli

issue:
Per the spec, ^=, $= and ~= with an empty value match nothing. [a*=""] is correct.

repro (Bun HTMLRewriter):

const html = '<i a="x"></i><i a=""></i><i a=" x"></i><i a="x "></i><i a="x  y"></i>';
for (const sel of ['[a^=""]', '[a$=""]', '[a*=""]', '[a~=""]']) {
  let n = 0;
  await new HTMLRewriter().on(sel, { element() { n++; } }).transform(new Response(html)).text();
  console.log(sel, n);
}
// [a^=""] 4
// [a$=""] 4
// [a*=""] 0
// [a~=""] 4

expected:
0 for all four (as Chrome, Firefox, Safari)

system:
Bun 1.4.3 (lol-html fork based on v2.7.2); the matcher code is unchanged in v3.0.1
macOS 27.0, arm64

Activity

  1. added 2 commits that reference this issue on Oct 27, 2026
    9e3d7c7
    dfd59d4
  2. added a commit that references this issue on Oct 27, 2026
    f14ca2f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions