Bug 238874 - [cssom] "set a CSS declaration" is broken for deferred properties
Summary: [cssom] "set a CSS declaration" is broken for deferred properties
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on: 238350
Blocks:
  Show dependency treegraph
 
Reported: 2022-04-06 10:14 PDT by Oriol Brufau
Modified: 2024-07-23 11:24 PDT (History)
4 users (show)

See Also:


Attachments
testcase (737 bytes, text/html)
2022-04-06 10:14 PDT, Oriol Brufau
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oriol Brufau 2022-04-06 10:14:39 PDT
Created attachment 456830 [details]
testcase

Run this testcase:

    <!DOCTYPE html>
    <div id="target"></div>
    <script>
    var cs = getComputedStyle(target);

    target.style.boxShadow = "0 0 0 100px blue";
    console.log(target.style.cssText); // box-shadow: blue 0px 0px 0px 100px;
    console.log(cs.boxShadow); // rgb(0, 0, 255) 0px 0px 0px 100px

    target.style.webkitBoxShadow = "0 0 0 100px red";
    console.log(target.style.cssText); // box-shadow: blue 0px 0px 0px 100px; -webkit-box-shadow: red 0px 0px 0px 100px;
    console.log(cs.boxShadow); // rgb(255, 0, 0) 0px 0px 0px 100px

    target.style.boxShadow = "0 0 0 100px green";
    console.log(target.style.cssText); // box-shadow: green 0px 0px 0px 100px; -webkit-box-shadow: red 0px 0px 0px 100px;
    console.log(cs.boxShadow); // rgb(0, 128, 0) 0px 0px 0px 100px
    </script>

Expected: green shadow.
Actual: red shadow.

box-shadow and -webkit-box-shadow are implemented as longhands that share a computed value.
During the CSS cascade, they are deferred and applied in parse order, so that the last one wins.
But CSSOM is broken, as seen above.
When you set boxShadow="0 0 0 100px green", it just updates the old value in place, without taking into account that it will be overridden by -webkit-box-shadow that appears later.

This needs the same fix that bug 226461 did for properties in a logical property group.
Comment 1 Radar WebKit Bug Importer 2022-04-13 10:15:15 PDT
<rdar://problem/91698692>
Comment 2 Ahmad Saleem 2024-07-23 11:23:53 PDT
It is still broken in Safari Technology Preview 199, while Chrome Canary 128 and Firefox Nightly 130 are matching each other and show 'green' for attached test case instead of 'red' (as in Safari).