Bug 220386

Summary: `direction: rtl` on the root cannot be unset from JS
Product: WebKit Reporter: Tim Guan-tin Chien [:timdream] <timdream>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, bfulgham, koivisto, rniwa, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: All   
OS: All   
Attachments:
Description Flags
direction-rtl.png none

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.