From 0de314507153b6ae17d15f3b03df10a7844ed224 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 10 Sep 2024 18:26:56 +0100 Subject: [PATCH] LibWeb: Don't crash when determining slot element auto directionality --- .../expected/HTML/dir-slot-auto-directionality.txt | 1 + .../input/HTML/dir-slot-auto-directionality.html | 14 ++++++++++++++ Userland/Libraries/LibWeb/DOM/Element.cpp | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/HTML/dir-slot-auto-directionality.txt create mode 100644 Tests/LibWeb/Text/input/HTML/dir-slot-auto-directionality.html diff --git a/Tests/LibWeb/Text/expected/HTML/dir-slot-auto-directionality.txt b/Tests/LibWeb/Text/expected/HTML/dir-slot-auto-directionality.txt new file mode 100644 index 00000000000..7f717ec84ec --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/dir-slot-auto-directionality.txt @@ -0,0 +1 @@ + Slot directionality: ltr diff --git a/Tests/LibWeb/Text/input/HTML/dir-slot-auto-directionality.html b/Tests/LibWeb/Text/input/HTML/dir-slot-auto-directionality.html new file mode 100644 index 00000000000..d7f134235ad --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/dir-slot-auto-directionality.html @@ -0,0 +1,14 @@ + + +
+ +
+ diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index d2ffe400089..1c00a833817 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -2643,7 +2643,7 @@ Optional Element::auto_directionality() const VERIFY(child->is_element()); // 2. Set childDirection to the auto directionality of child. - child_direction = static_cast(*this).auto_directionality(); + child_direction = static_cast(*child).auto_directionality(); } // 4. If childDirection is not null, then return childDirection.