mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibWeb: Implement Element.insertAdjacentText
This commit is contained in:
parent
d540e2ec98
commit
540c307009
Notes:
sideshowbarker
2024-07-17 06:30:50 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/540c307009 Pull-request: https://github.com/SerenityOS/serenity/pull/15400
|
@ -891,4 +891,16 @@ WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(String
|
|||
return JS::GCPtr<Element> { verify_cast<Element>(*returned_node) };
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-insertadjacenttext
|
||||
WebIDL::ExceptionOr<void> Element::insert_adjacent_text(String const& where, String const& data)
|
||||
{
|
||||
// 1. Let text be a new Text node whose data is data and node document is this’s node document.
|
||||
JS::NonnullGCPtr<Text> text = *heap().allocate<DOM::Text>(realm(), document(), data);
|
||||
|
||||
// 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.
|
||||
(void)TRY(insert_adjacent(where, move(text)));
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ public:
|
|||
bool is_actually_disabled() const;
|
||||
|
||||
WebIDL::ExceptionOr<JS::GCPtr<Element>> insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element);
|
||||
WebIDL::ExceptionOr<void> insert_adjacent_text(String const& where, String const& data);
|
||||
|
||||
protected:
|
||||
Element(Document&, DOM::QualifiedName);
|
||||
|
|
|
@ -54,6 +54,7 @@ interface Element : Node {
|
|||
readonly attribute long clientHeight;
|
||||
|
||||
[CEReactions] Element? insertAdjacentElement(DOMString where, Element element);
|
||||
undefined insertAdjacentText(DOMString where, DOMString data);
|
||||
[CEReactions] undefined insertAdjacentHTML(DOMString position, DOMString text);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue