ladybird icon indicating copy to clipboard operation
ladybird copied to clipboard

CSS custom property declarations must honor !important

Open awesomekling opened this issue 3 months ago • 1 comments

Simplified reduction:

<!doctype html><style>
    * { outline: 1px solid black; }
    :root {
        --size: 50px !important;
        --bg: green !important;
    }   
    main {
        --size: 200px;
        width: var(--size);
        height: var(--size);
        --bg: red;
        background: var(--bg);
    }   
</style><body><main>

Reduced from the ultra-wide search box on https://brave.com/

Image

awesomekling avatar Aug 31 '25 19:08 awesomekling

This is a consequence of us walking up the tree until we find an element with a custom property of the name we're after, instead of cascading them properly. A short-term fix would be to extend that to keep looking until we find an !important one (or not). The long-term fix is to compute and store custom properties per element.

AtkinsSJ avatar Aug 31 '25 19:08 AtkinsSJ