The :dir() CSS pseudo-class selector matches elements based on directionality, which is determined based on the HTML dir attribute. :dir(ltr) matches left-to-right text directionality, and :dir(rtl) matches elements with right-to-left text directionality. It is not equivalent to [dir] attribute selectors because it matches against directions inherited from an ancestor with the dir attribute, and because it matches against the direction computed from use of dir=auto (which determines directionality from the first character in the text with strong directionality).
This is largely an additive feature. However, as part of the process of preparing to ship the feature, we worked on more clearly specifying exactly how directionality in HTML works, and particularly how it interacts with shadow DOM. This work is occurring in https://github.com/whatwg/html/issues/3699 https://github.com/whatwg/html/pull/9554 and https://github.com/whatwg/html/pull/9796 . Since these changes to HTML directionality also affect the dirname attribute (which is a form submission feature), they have been implemented behind the same flag as the pseudo-class. However, they are likely to be low risk because the recommended way of using the dirname attribute is to use dir=auto on the same element as the dirname attribute, and that usage pattern should not be affected. This feature is part of Interop2023's focus area on CSS Pseudo-classes: https://wpt.fyi/interop-2023
Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?
no
Same as other pseudo-classes
WPT test plan (somewhat out of date, since recent CLs have added many tests) at https://github.com/web-platform-tests/wpt/issues/25569 Existing tests have names starting with "dir" in https://wpt.fyi/results/css/selectors and https://wpt.fyi/results/html/dom/elements/global-attributes PR for testing shadow DOM interaction at https://github.com/web-platform-tests/wpt/pull/29820 which will add additional tests
Shipping on desktop | 120 |
Shipping on Android | 120 |
Shipping on WebView | 120 |
Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).
PR at https://github.com/whatwg/html/pull/9796 to better define the feature, particularly how it relates to Shadow DOMTo unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/9936f6a6-53ea-444e-8edd-13d71adedc10%40chromium.org.