ladybird/Tests/LibWeb/Text/input/css/revert-ignores-layers.html
Sam Atkins bea47a2554 LibWeb/CSS: Correct behavior of revert inside a @layer
`revert` is supposed to revert to the previous cascade origin, but we
previously had it reverting to the previous layer. To support both,
track them separately during the cascade.

As part of this, we make `set_property_expanding_shorthands()` fall back
to `initial` if it can't find a previous value to revert to. Previously
we would just shrug and do nothing if that happened, which only works
if the value you want to revert to is whatever is currently in `style`.
That's no longer the case, because `revert` should skip over any layer
styles that have been applied since the previous origin.
2024-09-26 08:08:38 +02:00

35 lines
821 B
HTML

<!DOCTYPE html>
<style>
@layer A, B, C;
@layer A {
#target {
color: red;
}
}
@layer B {
#target {
color: blue;
}
}
@layer C {
#target {
color: revert;
}
}
</style>
<script src="../include.js"></script>
<div id="target"></div>
<div id="initial"></div>
<script>
test(() => {
const target = document.getElementById("target");
const initial = document.getElementById("target");
const expected = getComputedStyle(initial).color;
const actual = getComputedStyle(target).color;
if (expected === actual) {
println('PASS, revert skipped the layers');
} else {
println(`FAIL: got ${actual}, expected ${expected}`);
}
});
</script>