Skip to content

Extended CSS selector for textContent empty or whitespace #219686

@God-damnit-all

Description

@God-damnit-all

Prerequisites

  • I checked the documentation and found no answer;
  • I checked to make sure that this issue has not already been filed;
  • This is not an ad/bug report.

Problem description

I was looking to target a particular element adjacent to another particular element but only if it has no text content OR if its text content is only whitespace, e.g. <p></p> OR <p>&nbsp;</p>

This would be equivalent to the js elementNode.textContent.trim().length === 0. You can accomplish this right now with cssSelector:contains(/^\\s*$/) – but that's reliant on the regex engine and makes the rule line visually confusing.

Proposed solution

Perhaps to get the most use out of this, it could be a boolean:

css equivalent to... js
:visible-text(0) .textContent.trim().length === 0
:visible-text(1) .textContent.trim().length !== 0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions