mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:17:35 +00:00
LibWeb: Add simple implementation of Document.createElementNS
This commit is contained in:
parent
affb4ef01b
commit
449c6c5604
4 changed files with 14 additions and 3 deletions
|
@ -566,12 +566,21 @@ JS::Value Document::run_javascript(const StringView& source)
|
|||
return result;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createelement
|
||||
// FIXME: This only implements step 6 of the algorithm and does not take in options.
|
||||
NonnullRefPtr<Element> Document::create_element(const String& tag_name)
|
||||
{
|
||||
// FIXME: Let namespace be the HTML namespace, if this is an HTML document or this’s content type is "application/xhtml+xml", and null otherwise.
|
||||
return DOM::create_element(*this, tag_name, Namespace::HTML);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#internal-createelementns-steps
|
||||
// FIXME: This only implements step 4 of the algorithm and does not take in options.
|
||||
NonnullRefPtr<Element> Document::create_element_ns(const String& namespace_, const String& qualified_name)
|
||||
{
|
||||
return DOM::create_element(*this, qualified_name, namespace_);
|
||||
}
|
||||
|
||||
NonnullRefPtr<DocumentFragment> Document::create_document_fragment()
|
||||
{
|
||||
return adopt(*new DocumentFragment(*this));
|
||||
|
|
|
@ -146,6 +146,7 @@ public:
|
|||
JS::Value run_javascript(const StringView&);
|
||||
|
||||
NonnullRefPtr<Element> create_element(const String& tag_name);
|
||||
NonnullRefPtr<Element> create_element_ns(const String& namespace_, const String& qualifed_name);
|
||||
NonnullRefPtr<DocumentFragment> create_document_fragment();
|
||||
NonnullRefPtr<Text> create_text_node(const String& data);
|
||||
NonnullRefPtr<Comment> create_comment(const String& data);
|
||||
|
|
|
@ -19,6 +19,7 @@ interface Document : Node {
|
|||
ArrayFromVector querySelectorAll(DOMString selectors);
|
||||
|
||||
Element createElement(DOMString tagName);
|
||||
Element createElementNS(DOMString? namespace, DOMString qualifiedName);
|
||||
DocumentFragment createDocumentFragment();
|
||||
Text createTextNode(DOMString data);
|
||||
Comment createComment(DOMString data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue