diff --git a/Libraries/LibWeb/DOM/Range.cpp b/Libraries/LibWeb/DOM/Range.cpp index ea4c56449bf..7f5ebbb2983 100644 --- a/Libraries/LibWeb/DOM/Range.cpp +++ b/Libraries/LibWeb/DOM/Range.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2020, the SerenityOS developers. * Copyright (c) 2022, Luke Wilde * Copyright (c) 2022-2023, Andreas Kling - * Copyright (c) 2024, Jelle Raaijmakers + * Copyright (c) 2024-2025, Jelle Raaijmakers * * SPDX-License-Identifier: BSD-2-Clause */ @@ -807,12 +807,9 @@ bool Range::contains_node(GC::Ref node) const // https://dom.spec.whatwg.org/#partially-contained bool Range::partially_contains_node(GC::Ref node) const { - // A node is partially contained in a live range if it’s an inclusive ancestor of the live range’s start node but not its end node, or vice versa. - if (node->is_inclusive_ancestor_of(m_start_container) && node != m_end_container) - return true; - if (node->is_inclusive_ancestor_of(m_end_container) && node != m_start_container) - return true; - return false; + // A node is partially contained in a live range if it’s an inclusive ancestor of the live range’s start node but + // not its end node, or vice versa. + return node->is_inclusive_ancestor_of(m_start_container) != node->is_inclusive_ancestor_of(m_end_container); } // https://dom.spec.whatwg.org/#dom-range-insertnode