Re: [csswg-drafts] [css-highlight-api] maplike vs setlike (#5910)

Even if we allowed the same highlight object to be registered under multiple names, only one name can be reliably used to style the highlight. If the highlight were to be styled using multiple names, in the case of conflicting styles, the styles for the last registered name would always be painted on top and there would be no way to 'prioritize' the styles for names that were registered earlier. This could be confusing for authors because the paint order may not reflect the expected cascade order. For example, consider the following style rules where the same highlight object is registered with names 'foo' and 'bar', and 'bar' was the last registered name:
```
#p1::highlight(foo) {
    color: yellow;
}

#p1::highlight(bar) {
    color: red;
}

#p1::highlight(foo) {
   color: green;
}
```
Each rule targets the same highlight and has the same specificity, therefore authors may expect the last rule to win and the color of the highlighted content to be green. In reality, `::highlight(foo)` and `::highlight(bar)` are independent pseudo-element selectors and the highlight will be painted twice - once with the green color for 'foo' and once with the red color for 'bar'. Because 'bar' was registered later, the red color would be painted on top. Even if we used `color: green !important` for the third rule, the red color would still paint on top.

Though one could argue that this is not technically a cascade violation, it is definitely confusing behavior. So I think it is best to enforce that a highlight object can only be registered with a single unique name.

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


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

Received on Monday, 22 March 2021 07:10:15 UTC