mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Fix accessible-name computation for aria-labelledby cases
This change ensures that when the aria-labelledby attribute is used, the expected text from the element referenced in the aria-labelledby value appears in the computed accessible name. Otherwise, without this change, the expected text doesn’t appear in the computed accessible name.
This commit is contained in:
parent
b1587cc60f
commit
6d29afaa6c
Notes:
github-actions[bot]
2024-11-11 21:58:03 +00:00
Author: https://github.com/sideshowbarker Commit: https://github.com/LadybirdBrowser/ladybird/commit/6d29afaa6c7 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2194 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/AtkinsSJ
1 changed files with 4 additions and 2 deletions
|
@ -2227,7 +2227,8 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
|
|||
// b. Compute the text alternative of the current node beginning with step 2. Set the result to that text alternative.
|
||||
auto result = TRY(node->name_or_description(target, document, visited_nodes));
|
||||
// c. Append the result, with a space, to the accumulated text.
|
||||
TRY(Node::append_with_space(total_accumulated_text, result));
|
||||
total_accumulated_text.append(' ');
|
||||
total_accumulated_text.append(result);
|
||||
}
|
||||
// iii. Return the accumulated text.
|
||||
return total_accumulated_text.to_string();
|
||||
|
@ -2388,7 +2389,8 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
|
|||
total_accumulated_text.append(after->computed_values().content().data);
|
||||
}
|
||||
// v. Return the accumulated text if it is not the empty string ("").
|
||||
return total_accumulated_text.to_string();
|
||||
if (!total_accumulated_text.is_empty())
|
||||
return total_accumulated_text.to_string();
|
||||
// Important: Each node in the subtree is consulted only once. If text has been collected from a descendant, but is referenced by another IDREF in some descendant node, then that second, or subsequent, reference is not followed. This is done to avoid infinite loops.
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue