Re: [selectors] Assistance requested in figuring out the data model of pseudo-elements

On Wed, Nov 26, 2014 at 1:23 AM, Daniel Glazman
<daniel.glazman@disruptive-innovations.com> wrote:
> On 25/11/2014 22:37, Benjamin Poulain wrote:
>> In practice in WebKit, we have been using :matches() as a magic operator
>> that generates a disjunctive normal form of the selector.
>
> That sentence alone scares me to death.
>
> I still need to understand why we should expose this to the general
> public. How is it useful to web authors? Can you please give us a
> simple real-life use case?

Putting selectors in DNF isn't scary; it just means that `A
:matches(B, C) D` becomes `A B D, A C D` (selectors in a selector list
are basically related by disjunction).

In the call you asked for use-cases; I gave one there, but I can
repeat it here for posterity: the use-case is identical to normal
:matches().  Look in our own specs' stylesheet, for example, we have
the following:

```
pre .property::before, pre .property::after {
  content: "";
}
```

And a few more that work similarly.  With :matches() or something
similar, we could write:

```
pre .property:matches(::before, ::after) {
  content: "";
}
```

Saving ourselves a few keystrokes, and more importantly, reducing the
risk of the rest of the selector drifting apart when people
accidentally edit only one branch.

~TJ

Received on Wednesday, 26 November 2014 17:37:26 UTC