diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 64ff0637b70..0e8e5d7ac95 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -4663,8 +4663,8 @@ void Document::run_the_update_intersection_observations_steps(HighResolutionTime auto intersection_root_document = intersection_root.visit([](auto& node) -> GC::Ref { return node->document(); }); - if (!(observer->root().has() && &target->document() == intersection_root_document.ptr()) - || !(intersection_root.has>() && !target->is_descendant_of(*intersection_root.get>()))) { + // NOTE: Check if target has a layout node is not in the spec but required to match other browsers. + if (target->layout_node() && (!(observer->root().has() && &target->document() == intersection_root_document.ptr()) || !(intersection_root.has>() && !target->is_descendant_of(*intersection_root.get>())))) { // 4. Set targetRect to the DOMRectReadOnly obtained by getting the bounding box for target. target_rect = target->get_bounding_client_rect(); diff --git a/Tests/LibWeb/Text/expected/IntersectionObserver/box-without-layout-node-should-not-intersect.txt b/Tests/LibWeb/Text/expected/IntersectionObserver/box-without-layout-node-should-not-intersect.txt new file mode 100644 index 00000000000..263bc73a056 --- /dev/null +++ b/Tests/LibWeb/Text/expected/IntersectionObserver/box-without-layout-node-should-not-intersect.txt @@ -0,0 +1,2 @@ +flip #container to visible +#nested is visible diff --git a/Tests/LibWeb/Text/input/IntersectionObserver/box-without-layout-node-should-not-intersect.html b/Tests/LibWeb/Text/input/IntersectionObserver/box-without-layout-node-should-not-intersect.html new file mode 100644 index 00000000000..ee9d07c239c --- /dev/null +++ b/Tests/LibWeb/Text/input/IntersectionObserver/box-without-layout-node-should-not-intersect.html @@ -0,0 +1,24 @@ + + + + \ No newline at end of file