|
@@ -89,18 +89,30 @@
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
|
|
-NonnullRefPtr<Element> create_element(Document& document, FlyString tag_name, FlyString namespace_)
|
|
|
+// https://dom.spec.whatwg.org/#concept-create-element
|
|
|
+NonnullRefPtr<Element> create_element(Document& document, FlyString local_name, FlyString namespace_, FlyString prefix)
|
|
|
{
|
|
|
- auto lowercase_tag_name = tag_name.to_lowercase();
|
|
|
+ // 1. If prefix was not given, let prefix be null.
|
|
|
+ // NOTE: This is already taken care of by `prefix` having a default value.
|
|
|
|
|
|
- FlyString prefix;
|
|
|
- auto parts = tag_name.view().split_view(':');
|
|
|
- if (parts.size() > 1) {
|
|
|
- prefix = parts[0];
|
|
|
- tag_name = tag_name.view().substring_view_starting_from_substring(parts[1]);
|
|
|
- }
|
|
|
+ // FIXME: 2. If is was not given, let is be null.
|
|
|
+ // FIXME: 3. Let result be null.
|
|
|
+ // FIXME: 4. Let definition be the result of looking up a custom element definition given document, namespace, localName, and is.
|
|
|
+ // FIXME: 5. If definition is non-null, and definition’s name is not equal to its local name (i.e., definition represents a customized built-in element), then: ...
|
|
|
+ // FIXME: 6. Otherwise, if definition is non-null, then: ...
|
|
|
|
|
|
- auto qualified_name = QualifiedName(tag_name, prefix, namespace_);
|
|
|
+ // 7. Otherwise:
|
|
|
+ // 1. Let interface be the element interface for localName and namespace.
|
|
|
+ // 2. Set result to a new element that implements interface, with no attributes, namespace set to namespace, namespace prefix set to prefix,
|
|
|
+ // local name set to localName, custom element state set to "uncustomized", custom element definition set to null, is value set to is,
|
|
|
+ // and node document set to document.
|
|
|
+ // FIXME: 3. If namespace is the HTML namespace, and either localName is a valid custom element name or is is non-null,
|
|
|
+ // then set result’s custom element state to "undefined".
|
|
|
+ // 8. Return result.
|
|
|
+
|
|
|
+ auto lowercase_tag_name = local_name.to_lowercase();
|
|
|
+
|
|
|
+ auto qualified_name = QualifiedName { local_name, prefix, namespace_ };
|
|
|
if (lowercase_tag_name == HTML::TagNames::a)
|
|
|
return adopt_ref(*new HTML::HTMLAnchorElement(document, move(qualified_name)));
|
|
|
if (lowercase_tag_name == HTML::TagNames::area)
|