Re: [csswg-drafts] [selectors] decide on :blank (#1967)

I think a simpler route would be to have four different selectors (two of which already exist), each clearly fulfilling a different purpose, which would also help to avoid any breaking changes for that 2.5% that @foolip (via @lilles) pointed out and also to attempt to be more future proof:

* `:empty` – no children (no whitespace allowed)
* `:blank` – empty value (for form fields and related elements)
   _being discussed here:_ https://github.com/whatwg/html/issues/8451
* `:whitespace-only` – no child element nodes or non-whitespace text nodes (whitespace allowed)
* `:text-only` – no child element nodes (text and whitespace allowed)

#### Related notes:

* `:text-only` is technically possible today (AFAICT) as a decorator using `:has()`
* `:whitespace-only` could be nearly identical in implementation to `:empty` with the slight difference of assessing trimmed contents rather than untrimmed contents

<table>
  <colgroup>
    <col span="2" />
    <col />
  </colgroup>
  <thead>
    <tr>
      <th>Pseudo selector</th>
      <th>Decorator / implementation note</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><pre>:empty</pre></td>
      <td>implementation stays as is, matches elements without any contents (whitespace will not match), spec is adjusted to exclude whitespace as allowed contents to match <code>:empty</code></td>
    </tr>
    <tr></tr>
    <tr>
      <td><pre>:blank</pre></td>
      <td>matches empty values as spec'd here and discussed here: https://github.com/whatwg/html/issues/8451</td>
    </tr>
    <tr></tr>
    <tr>
      <td><pre>:whitespace-only</pre></td>
      <td>similar to <code>:empty</code> but assesses the element's trimmed contents rather than untrimmed to ignore whitespace when evaluating for emptiness</td>
    </tr>
    <tr></tr>
    <tr>
      <td><pre>:text-only</pre></td>
      <td>decorator for <code>&:not(:has(> *))</code> to match any elements without any child elements</td>
    </tr>
  </tbody>
</table>

-- 
GitHub Notification of comment by brandonmcconnell
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1967#issuecomment-1298882009 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 1 November 2022 17:39:25 UTC