Re: [csswg-drafts] [css-selectors] :stuck pseudo-class feature suggestion

> Nobody in their right mind would write could like that in your example.

First, don't be ableist. 

Second, you'd be surprised/horrified what people write.

> You could simply disallow/make invalid anything that could cause an infinite loop.

Say we did this, and explicitly disallowed setting `position` in a rule targeting a `:stuck` element.  Okay, this works for this case.  

Next week, someone comes up with a similar circularity they want to allow (like [my Toggle States proposal](https://tabatkins.github.io/specs/css-toggle-states/), which has properties interacting with `:checked`).  We disallow that circularity too.

Now someone writes

```css
.foo { toggle-states: 2; toggle-initial: 1; } /* makes it checked */
:checked { position: sticky; }
:stuck { toggle-states: none; }
```

When it's checked, it becomes sticky. (Assume the page is scrolled such that it becomes stuck immediately.)  When it's stuck, it becomes uncheckable, which means it's no longer sticky, so it's not stuck, so it goes back to being checkable, and so it's checked, and so it's sticky, and so it's stuck, and so it's uncheckable...

If you add a third selector/property pair, the number of cycles you need to manage gets even larger.

The only way around this is to define that *none* of the properties that affect selectors can be used in rules using *any* of the selectors affected by properties.  That ends up with a lot of confusing action-at-a-distance: it's weird that using `:checked` means that you can't set `position: sticky` any more.

Instead of doing all of this, so far we've just short-circuited the entire debate and disallowed selectors from being affected by properties.

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

Received on Thursday, 27 July 2017 20:36:01 UTC