Bug 220386 - `direction: rtl` on the root cannot be unset from JS
Summary: `direction: rtl` on the root cannot be unset from JS
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari Technology Preview
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-01-06 15:01 PST by Tim Guan-tin Chien [:timdream]
Modified: 2022-08-06 19:35 PDT (History)
7 users (show)

See Also:


Attachments
direction-rtl.png (801.87 KB, image/png)
2021-01-06 15:01 PST, Tim Guan-tin Chien [:timdream]
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Guan-tin Chien [:timdream] 2021-01-06 15:01:56 PST
Created attachment 417131 [details]
direction-rtl.png

STR:

1. Load this URL: data:text/html,<body style="direction: rtl">text</body>
2. Open the inspector and uncheck the CSS rule, or use the JS console and run `document.body.style.direction = ""`

Alternative STR:

1. Load this URL: data:text/html,<body style="direction: rtl">text<script>setTimeout(() => document.body.style.direction = "", 1000)</script></body>

Expected:

The direction should flip to ltr (default)

Actual:

The page stays at rtl.
Comment 1 Radar WebKit Bug Importer 2021-01-06 15:02:51 PST
<rdar://problem/72866732>
Comment 2 Tim Guan-tin Chien [:timdream] 2021-01-06 15:21:28 PST
STP Release 118 (Safari 14.1, WebKit 15611.1.9)
macOS 10.15.7 (19H15)
Comment 3 Alexey Proskuryakov 2021-01-06 18:37:14 PST
Setting document.body.style.direction to "ltr" works; removeProperty("direction") also fails to update the direction.
Comment 4 Simon Fraser (smfr) 2021-01-09 11:54:12 PST
Seems to be an issue on the root (body or html) only.
Comment 5 Simon Fraser (smfr) 2021-01-09 12:09:10 PST
I think this is about this code in resolveForDocument():

        if (bodyRenderer && !docElementRenderer->style().hasExplicitlySetDirection())
            documentStyle.setDirection(bodyRenderer->style().direction());
        else
            documentStyle.setDirection(docElementRenderer->style().direction());

which seems to put the old body style on the document.