Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibWeb: Update Element::directionality() for bdi elements to match spec #4031

Merged
merged 1 commit into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Libraries/LibWeb/DOM/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3275,10 +3275,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<HTML::HTMLInputElement>(this) && static_cast<HTML::HTMLInputElement const&>(*this).type_state() == HTML::HTMLInputElement::TypeAttributeState::Telephone) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading