1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-06 22:37:35 +00:00

LibWeb: Port Element::insert_adjacent from ByteString

This commit is contained in:
Shannon Booth 2024-01-13 20:12:29 +13:00 committed by Andreas Kling
parent bd2fe3dcaa
commit e6861cb5ef
2 changed files with 4 additions and 4 deletions

View file

@ -1468,7 +1468,7 @@ WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position,
} }
// https://dom.spec.whatwg.org/#insert-adjacent // https://dom.spec.whatwg.org/#insert-adjacent
WebIDL::ExceptionOr<JS::GCPtr<Node>> Element::insert_adjacent(ByteString const& where, JS::NonnullGCPtr<Node> node) WebIDL::ExceptionOr<JS::GCPtr<Node>> Element::insert_adjacent(StringView where, JS::NonnullGCPtr<Node> node)
{ {
// To insert adjacent, given an element element, string where, and a node node, run the steps associated with the first ASCII case-insensitive match for where: // To insert adjacent, given an element element, string where, and a node node, run the steps associated with the first ASCII case-insensitive match for where:
if (Infra::is_ascii_case_insensitive_match(where, "beforebegin"sv)) { if (Infra::is_ascii_case_insensitive_match(where, "beforebegin"sv)) {
@ -1512,7 +1512,7 @@ WebIDL::ExceptionOr<JS::GCPtr<Node>> Element::insert_adjacent(ByteString const&
WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element) WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element)
{ {
// The insertAdjacentElement(where, element) method steps are to return the result of running insert adjacent, give this, where, and element. // The insertAdjacentElement(where, element) method steps are to return the result of running insert adjacent, give this, where, and element.
auto returned_node = TRY(insert_adjacent(where.to_byte_string(), move(element))); auto returned_node = TRY(insert_adjacent(where, element));
if (!returned_node) if (!returned_node)
return JS::GCPtr<Element> { nullptr }; return JS::GCPtr<Element> { nullptr };
return JS::GCPtr<Element> { verify_cast<Element>(*returned_node) }; return JS::GCPtr<Element> { verify_cast<Element>(*returned_node) };
@ -1526,7 +1526,7 @@ WebIDL::ExceptionOr<void> Element::insert_adjacent_text(String const& where, Str
// 2. Run insert adjacent, given this, where, and text. // 2. Run insert adjacent, given this, where, and text.
// Spec Note: This method returns nothing because it existed before we had a chance to design it. // Spec Note: This method returns nothing because it existed before we had a chance to design it.
(void)TRY(insert_adjacent(where.to_byte_string(), text)); (void)TRY(insert_adjacent(where, text));
return {}; return {};
} }

View file

@ -391,7 +391,7 @@ private:
void invalidate_style_after_attribute_change(FlyString const& attribute_name); void invalidate_style_after_attribute_change(FlyString const& attribute_name);
WebIDL::ExceptionOr<JS::GCPtr<Node>> insert_adjacent(ByteString const& where, JS::NonnullGCPtr<Node> node); WebIDL::ExceptionOr<JS::GCPtr<Node>> insert_adjacent(StringView where, JS::NonnullGCPtr<Node> node);
void enqueue_an_element_on_the_appropriate_element_queue(); void enqueue_an_element_on_the_appropriate_element_queue();