-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@layer] Add tests for !important styles in @layer
#33767
Comments
|
I haven't looked carefully at what tests exist, but I can answer what should happen in this case. The layer order (including the placement of unlayered styles) is reversed in the
In this example: <link rel=stylesheet href="data:text/css,@layer{target{background-color:green !important}}">
<style>
@layer A { target { background-color: red !important} }
</style>
<link rel=stylesheet href="data:text/css,@layer{target{background-color:green !important}}">The result should be In this example: @layer { target { color: red !important; } }
@layer { target { color: green !important; } }Chrome Canary has the correct behavior. The first layer important declaration should override the second layer important declaration. If green is intended as a sign of success, these declarations should be switched. |
Looking at the Chromium-CL that introduced this test, it's testing a style sharing/caching issue in Chrome. It should probably have a rel=help link to the crbug to make that visible.
This is red in both Chrome Canary and Chrome Stable for me on Mac.
Not for me. |
🤔 I normally double check before reporting an issue but I am sure you are right as I can no longer reproduce this. Unsure if I confused the color in the inspector for the actual color or if there was something else on my end.
It was indeed not clear to me that this test was added for a specific Chrome issue. Would it be possible to add some general tests for There are some tests with |
Yes, feel free to add a PR with some basic !important tests. |
|
@lilles I've added a PR with some basic tests. I've also been able to pinpoint the issue I mentioned earlier. In Chrome Canary important layered styles give unexpected results only when there previously was a style element with only unlayered important styles. These tests pass for all current versions of Safari, Chrome, Firefox. My initial description of the issue above was incomplete and when I tried to reproduce it from that description I was unable to. Which is why it seemed to have gone away. |
|
Also filed a bug report about this issue : https://bugs.chromium.org/p/chromium/issues/detail?id=1326791 |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.


Currently the behaviour of
!importantstyles combined with@layerrules doesn't have sufficient test coverage.The most relevant test I could find was added in this PR : #31944
It does however appear that this test has a bug and will always pass (I might be wrong about this) :
Safari TP and Chrome Canary have also started to diverge.
For this style the current stable versions both give priority to
red.Chrome Canary now gives priority to
green.I am not a 100% sure which one is actually correct.
There is also some weirdness in the inspector for both stable Safari and Chrome.
Having better tests for
!importanttogether with@layermight also help to resolve those issues.The text was updated successfully, but these errors were encountered: