Skip to content

Add text() pseudo-attribute selector #15

Description

@kzu

Being able to filter or select nodes based on their text content is
something that is supported in XPath since its inception. CSS doesn't
allow this, but since we're in a bridge where everything runs as XPath
expressions in the end, it would be convenient to extend the CSS
syntax to allow for this.

Proposal is to simply allow text() as if it were an attribute name, in
the same context and with the same capabilities as if it were an attribute
value retrieval. This would allow it to also participate in all text matching
capabilities of the attribute selector.

For example:

  • Get div with text foo: div[text()=foo]
  • Get divs with text ending in suffix: div[text()$=suffix]

All the other matching strategies, like *=, ^= should also work as-is.

Activity

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions