Re: [csswg-drafts] [CSS Import Once] @import-once, or some syntax for importing a stylesheet only once (#6130)

Looks like I overlooked a behavior of Layers.

To make the topic easier to understand, I decided to make a working reproduction of the original issue on CodePen. See this set of pens:

- https://codepen.io/trusktr/pen/vYMEPYe (a.css)
- https://codepen.io/trusktr/pen/bGJNZGm (b.css, imports a.css)
- https://codepen.io/trusktr/pen/eYomXmY (my-feature1.css, imports b.css)
- https://codepen.io/trusktr/pen/YzMPgPx (c.css, imports b.css)
- https://codepen.io/trusktr/pen/poBvYJm (my-feature2.css, imports c.css)
- https://codepen.io/trusktr/pen/MWRYxwN (my-page.css, imports my-feature1.css and my-feature2.css) - this is the pen whose final result we care about.

We can see that in the final result, the text is **pink**, although we expect it to be **cyan**. This is because `a.css` gets applied once during the import of `my-feature1.css` which has the cyan override, then `a.css` gets applied again during the import of `my-feature2.css` which does not have the cyan override so the *second* instance of `a.css` sets it back to `pink` again.

Now, here's the same thing ported to Layers:

- https://codepen.io/trusktr/pen/RwONEOP (a.css)
- https://codepen.io/trusktr/pen/abxzPrX (b.css, imports a.css)
- https://codepen.io/trusktr/pen/poBvGza (my-feature1.css, imports b.css)
- https://codepen.io/trusktr/pen/KKYwbjZ (c.css, imports b.css)
- https://codepen.io/trusktr/pen/MWRYLwX (my-feature2.css, imports c.css)
- https://codepen.io/trusktr/pen/XWQJOdO (my-page.css, imports my-feature1.css and my-feature2.css) - this is the pen whose final result we care about.

In the layers example, the final result is **cyan** as we wanted, not **pink**. Seems like this will get confusing because we still have all the duplicate cheets, but now we have more layers than is obvious. If I'm seeing thing correctly, I may be seeing other issues. But first, what exactly is happening with the layers version? 

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


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

Received on Sunday, 3 March 2024 21:40:49 UTC