mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
LibWeb: Implement Element.insertAdjacentText
This commit is contained in:
parent
d540e2ec98
commit
540c307009
3 changed files with 14 additions and 0 deletions
|
@ -891,4 +891,16 @@ WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(String
|
||||||
return JS::GCPtr<Element> { verify_cast<Element>(*returned_node) };
|
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;
|
bool is_actually_disabled() const;
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::GCPtr<Element>> insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element);
|
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:
|
protected:
|
||||||
Element(Document&, DOM::QualifiedName);
|
Element(Document&, DOM::QualifiedName);
|
||||||
|
|
|
@ -54,6 +54,7 @@ interface Element : Node {
|
||||||
readonly attribute long clientHeight;
|
readonly attribute long clientHeight;
|
||||||
|
|
||||||
[CEReactions] Element? insertAdjacentElement(DOMString where, Element element);
|
[CEReactions] Element? insertAdjacentElement(DOMString where, Element element);
|
||||||
|
undefined insertAdjacentText(DOMString where, DOMString data);
|
||||||
[CEReactions] undefined insertAdjacentHTML(DOMString position, DOMString text);
|
[CEReactions] undefined insertAdjacentHTML(DOMString position, DOMString text);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue