ladybird/Tests/LibWeb/Text/input/css/custom-property-computed-value.html
Sam Atkins 26acd897bf LibWeb: Produce computed values for custom properties
Custom properties are required to produce a computed value just like
regular properties. The computed value is defined in the spec as
"specified value with variables substituted, or the guaranteed-invalid
value", though in reality all arbitrary substitution functions should be
substituted, not just `var()`.

To support this, we parse the CSS-wide keywords normally in custom
properties, instead of ignoring them. We don't yet handle all of them
properly, and because that will require us to cascade them like regular
properties. This is just enough to prevent regressions when implementing
ASFs.

Our output in this new test is not quite correct, because of the awkward
way we handle whitespace in property values - so it has 3 spaces in the
middle instead of 1, until that's fixed.

It's possible this computed-value production should go in
cascade_custom_properties(), but I had issues with that. Hopefully once
we start cascading custom properties properly, it'll be clearer how
this should all work.
2025-07-09 16:44:20 +01:00

12 lines
301 B
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<style>
#a { --foo: "Hello"; }
#b { --bar: var(--foo) "world!"; }
</style>
<div id="a"><div id="b"></div></div>
<script>
test(() => {
println(getComputedStyle(document.getElementById("b")).getPropertyValue("--bar"));
});
</script>