[a~=""] matches elements · Issue #1910 · fb55/css-select · GitHub
Skip to content

[a~=""] matches elements #1910

Open

Description

@robertmorelli

issue:
Per the spec, ~= with an empty value matches nothing. css-select matches a="" and values with leading, trailing or doubled spaces.

repro:

import { selectAll } from "css-select";
import { parseDocument } from "htmlparser2";
const doc = parseDocument('<i a=""></i><i a=" x"></i><i a="x "></i><i a="x  y"></i>');
console.log(selectAll('[a~=""]', doc).length); // 4

expected:
prints 0 (as Chrome, Firefox, Safari)

system:
css-select 7.0.0, Node 25.8.1
macOS 27.0, arm64

Activity

  1. NevanDeCoteau commented on Oct 13, 2026

    @NevanDeCoteau

    Hi. I think this would be a good fit for my first open-source contribution. I’m new to css-select and its codebase, but I’d like to try this issue if it’s still available.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions