Bug 227196 - document.documentElement.removeAttribute('dir') won't reset to previous state
Summary: document.documentElement.removeAttribute('dir') won't reset to previous state
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari 14
Hardware: Mac (Intel) macOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-20 12:34 PDT by diegocardoso
Modified: 2023-05-23 02:44 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description diegocardoso 2021-06-20 12:34:56 PDT
If you have a page in LTR mode and call `document.documentElement.setAttribute('dir', 'rtl')` to force the page to be in RTL mode, you would expect that calling `document.documentElement.removeAttribute('dir')` restores it to the previous state. But in Safari, unlike Chrome and Firefox, nothing happens and the direction mode remains on RTL. You can force it to go back to LRT by calling `document.documentElement.setAttribute('dir', 'ltr').

I couldn't find on the specs (https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute) any description of how it should behave on this case, but since other browsers that I tested work similarly, meaning that it falls back to the default direction mode, I decided to fill this bug.

You can try it on this small example I created: https://jsfiddle.net/diegocardoso/chm7yk5e/7/
Comment 1 Radar WebKit Bug Importer 2021-06-27 12:35:17 PDT
<rdar://problem/79842142>
Comment 2 Ahmad Saleem 2023-05-23 02:44:08 PDT
I am unable to reproduce this bug in Safari 16.5, where ticking makes it RTL while unticking make it go back to original state and it matches with Chrome Canary 115 and Firefox Nightly 115.

Marking this as "RESOLVED CONFIGURATION CHANGED", if it is still an issue, please reopen with updated test case / reduction.