diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 290a1ce26d8..623aabffe5e 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -3291,10 +3291,18 @@ Element::Directionality Element::directionality() const // -> undefined VERIFY(!maybe_dir.has_value()); - // FIXME: If element is a bdi element: - // FIXME: 1. Let result be the auto directionality of element. - // FIXME: 2. If result is null, then return 'ltr'. - // FIXME: 3. Return result. + // If element is a bdi element: + if (local_name() == HTML::TagNames::bdi) { + // 1. Let result be the auto directionality of element. + auto result = auto_directionality(); + + // 2. If result is null, then return 'ltr'. + if (!result.has_value()) + return Directionality::Ltr; + + // 3. Return result. + return result.release_value(); + } // If element is an input element whose type attribute is in the Telephone state: if (is(this) && static_cast(*this).type_state() == HTML::HTMLInputElement::TypeAttributeState::Telephone) { diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/dir-pseudo-on-bdi-element.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/dir-pseudo-on-bdi-element.txt index a3cb3b13b94..d3895c0c64e 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/dir-pseudo-on-bdi-element.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/dir-pseudo-on-bdi-element.txt @@ -2,10 +2,9 @@ Harness status: OK Found 5 tests -3 Pass -2 Fail -Fail bdi element without dir content attribute -Fail bdi element with invalid dir content attribute +5 Pass +Pass bdi element without dir content attribute +Pass bdi element with invalid dir content attribute Pass bdi element with dir=auto content attribute Pass bdi element with dir=ltr content attribute Pass bdi element with dir=rtl content attribute \ No newline at end of file