Bug 255568

Summary: :dir pseudo class doesn't invalidate after removing dir content attribute from document element
Product: WebKit Reporter: sorvell
Component: CSSAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Normal CC: koivisto, rniwa, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: Unspecified   
OS: Unspecified   

Description sorvell 2023-04-17 17:56:22 PDT
When direction is dynamically changed by setting the `dir` attribute to `rtl`, styles matching `:dir(rtl)` are applied as expected; however, if the `dir` attribute is removed, styles matching `:dir(rtl)` unexpectedly still apply.

See this reproduction: https://lit.dev/playground/#gist=b7c7e390a923d0a54b5c3211bd69a668

Expected: 
1. check the `rtl` checkbox to set document to rtl mode
2. styles matching `:dir(rtl)` apply
3. uncheck the `rtl` checkbox to set document back to default (ltr) direction
4. styles matching `:dir(rtl)` do *not* apply

Actual: 
1. check the `rtl` checkbox to set document to rtl mode
2. styles matching `:dir(rtl)` apply
3. uncheck the `rtl` checkbox to set document back to default (ltr) direction
4. styles matching `:dir(rtl)` *unexpectedly do* apply
Comment 1 Radar WebKit Bug Importer 2023-04-24 17:57:19 PDT
<rdar://problem/108480507>
Comment 2 Ryosuke Niwa 2023-04-24 22:18:45 PDT
Pull request: https://github.com/WebKit/WebKit/pull/13134
Comment 3 EWS 2023-04-25 02:27:25 PDT
Committed 263357@main (a3084fe071c6): <https://commits.webkit.org/263357@main>

Reviewed commits have been landed. Closing PR #13134 and removing active labels.