LibWeb: Don't crash when determining slot element auto directionality

This commit is contained in:
Tim Ledbetter 2024-09-10 18:26:56 +01:00 committed by Tim Flynn
parent 1b74104c17
commit 0de3145071
Notes: github-actions[bot] 2024-09-10 19:59:53 +00:00
3 changed files with 16 additions and 1 deletions

View file

@ -0,0 +1 @@
Slot directionality: ltr

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<div id="root">
<span></span>
</div>
<script>
const root = document.getElementById("root");
test(() => {
const shadowTree = `<slot dir="auto"></slot>`;
const shadow = document.querySelector("#root").attachShadow({mode: "open"});
shadow.innerHTML = shadowTree;
println(`Slot directionality: ${getComputedStyle(shadow.querySelector("slot")).direction}`);
});
</script>

View file

@ -2643,7 +2643,7 @@ Optional<Element::Directionality> Element::auto_directionality() const
VERIFY(child->is_element());
// 2. Set childDirection to the auto directionality of child.
child_direction = static_cast<HTML::HTMLElement const&>(*this).auto_directionality();
child_direction = static_cast<HTML::HTMLElement const&>(*child).auto_directionality();
}
// 4. If childDirection is not null, then return childDirection.