Skip to content

Commit add380d

Browse files
Noah55-makergmta
authored andcommitted
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 5f12b2a commit add380d

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
@@ -3291,10 +3291,18 @@ Element::Directionality Element::directionality() const
32913291
// -> undefined
32923292
VERIFY(!maybe_dir.has_value());
32933293

3294-
// FIXME: If element is a bdi element:
3295-
// FIXME: 1. Let result be the auto directionality of element.
3296-
// FIXME: 2. If result is null, then return 'ltr'.
3297-
// FIXME: 3. Return result.
3294+
// If element is a bdi element:
3295+
if (local_name() == HTML::TagNames::bdi) {
3296+
// 1. Let result be the auto directionality of element.
3297+
auto result = auto_directionality();
3298+
3299+
// 2. If result is null, then return 'ltr'.
3300+
if (!result.has_value())
3301+
return Directionality::Ltr;
3302+
3303+
// 3. Return result.
3304+
return result.release_value();
3305+
}
32983306

32993307
// If element is an input element whose type attribute is in the Telephone state:
33003308
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)