Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5f7d915

Browse files
committedMar 21, 2025·
LibWeb: Update Element::directionality() for bdi elements to match spec
This fixes three WPT test cases at html/dom/elements/global-attributes/dir-assorted.window.html Update test expectations for Tests/LibWeb/Text/expected/wpt-import/css/selectors/dir-pseudo-on-bdi-element.txt
1 parent c528c01 commit 5f7d915

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed
 

‎Libraries/LibWeb/DOM/Element.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -3275,10 +3275,18 @@ Element::Directionality Element::directionality() const
32753275
// -> undefined
32763276
VERIFY(!maybe_dir.has_value());
32773277

3278-
// FIXME: If element is a bdi element:
3279-
// FIXME: 1. Let result be the auto directionality of element.
3280-
// FIXME: 2. If result is null, then return 'ltr'.
3281-
// FIXME: 3. Return result.
3278+
// If element is a bdi element:
3279+
if (local_name() == HTML::TagNames::bdi) {
3280+
// 1. Let result be the auto directionality of element.
3281+
auto result = auto_directionality();
3282+
3283+
// 2. If result is null, then return 'ltr'.
3284+
if (!result.has_value())
3285+
return Directionality::Ltr;
3286+
3287+
// 3. Return result.
3288+
return result.release_value();
3289+
}
32823290

32833291
// If element is an input element whose type attribute is in the Telephone state:
32843292
if (is<HTML::HTMLInputElement>(this) && static_cast<HTML::HTMLInputElement const&>(*this).type_state() == HTML::HTMLInputElement::TypeAttributeState::Telephone) {

‎Tests/LibWeb/Text/expected/wpt-import/css/selectors/dir-pseudo-on-bdi-element.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ Harness status: OK
22

33
Found 5 tests
44

5-
3 Pass
6-
2 Fail
7-
Fail bdi element without dir content attribute
8-
Fail bdi element with invalid dir content attribute
5+
5 Pass
6+
Pass bdi element without dir content attribute
7+
Pass bdi element with invalid dir content attribute
98
Pass bdi element with dir=auto content attribute
109
Pass bdi element with dir=ltr content attribute
1110
Pass bdi element with dir=rtl content attribute

0 commit comments

Comments
 (0)
Please sign in to comment.