diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 1b023d32555..e6f442523c4 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -293,24 +293,14 @@ WebIDL::ExceptionOr validate_and_extract(JS::Realm& realm, Option auto local_name = qualified_name; // 4. If qualifiedName contains a U+003A (:): - if (qualified_name.code_points().contains(':')) { + auto split_result = qualified_name.bytes_as_string_view().split_view(':', SplitBehavior::KeepEmpty); + if (split_result.size() > 1) { // 1. Let splitResult be the result of running strictly split given qualifiedName and U+003A (:). - // FIXME: Use the "strictly split" algorithm - - size_t index = 0; - for (auto code_point : qualified_name.code_points()) { - if (code_point == ':') - break; - index++; - } - // 2. Set prefix to splitResult[0]. - auto prefix_view = qualified_name.code_points().unicode_substring_view(0, index); - prefix = MUST(FlyString::from_utf8(prefix_view.as_string())); + prefix = MUST(FlyString::from_utf8(split_result[0])); // 3. Set localName to splitResult[1]. - auto local_name_view = qualified_name.code_points().unicode_substring_view(index + 1); - local_name = MUST(FlyString::from_utf8(local_name_view.as_string())); + local_name = MUST(FlyString::from_utf8(split_result[1])); } // 5. If prefix is not a valid namespace prefix, then throw an "InvalidCharacterError" DOMException. diff --git a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/DOMImplementation-createDocument.txt b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/DOMImplementation-createDocument.txt index a462f935424..54505871689 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/DOMImplementation-createDocument.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/DOMImplementation-createDocument.txt @@ -2,8 +2,7 @@ Harness status: OK Found 430 tests -426 Pass -4 Fail +430 Pass Pass DOMImplementation.createDocument(namespace, qualifiedName, doctype) Pass createDocument test: null,null,null,null Pass createDocument test: metadata for null,null,null @@ -94,7 +93,7 @@ Pass createDocument test: characterSet aliases for undefined,"foo1",null Pass createDocument test: undefined,":foo",null,"INVALID_CHARACTER_ERR" Pass createDocument test: undefined,"f:oo",null,"NAMESPACE_ERR" Pass createDocument test: undefined,"foo:",null,"INVALID_CHARACTER_ERR" -Fail createDocument test: undefined,"f::oo",null,"INVALID_CHARACTER_ERR" +Pass createDocument test: undefined,"f::oo",null,"INVALID_CHARACTER_ERR" Pass createDocument test: undefined,"xml",null,null Pass createDocument test: metadata for undefined,"xml",null Pass createDocument test: characterSet aliases for undefined,"xml",null @@ -125,11 +124,11 @@ Pass createDocument test: "http://example.com/",":foo",null,"INVALID_CHARACTER_E Pass createDocument test: "http://example.com/","f:oo",null,null Pass createDocument test: metadata for "http://example.com/","f:oo",null Pass createDocument test: characterSet aliases for "http://example.com/","f:oo",null -Fail createDocument test: "http://example.com/","f:o:o",null,null +Pass createDocument test: "http://example.com/","f:o:o",null,null Pass createDocument test: metadata for "http://example.com/","f:o:o",null Pass createDocument test: characterSet aliases for "http://example.com/","f:o:o",null Pass createDocument test: "http://example.com/","foo:",null,"INVALID_CHARACTER_ERR" -Fail createDocument test: "http://example.com/","f::oo",null,"INVALID_CHARACTER_ERR" +Pass createDocument test: "http://example.com/","f::oo",null,"INVALID_CHARACTER_ERR" Pass createDocument test: "http://example.com/","a:0",null,"INVALID_CHARACTER_ERR" Pass createDocument test: "http://example.com/","0:a",null,null Pass createDocument test: metadata for "http://example.com/","0:a",null @@ -214,7 +213,7 @@ Pass createDocument test: characterSet aliases for "http://example.com/","XMLNS: Pass createDocument test: "http://example.com/","xmlfoo:bar",null,null Pass createDocument test: metadata for "http://example.com/","xmlfoo:bar",null Pass createDocument test: characterSet aliases for "http://example.com/","xmlfoo:bar",null -Fail createDocument test: "http://example.com/","prefix::local",null,"INVALID_CHARACTER_ERR" +Pass createDocument test: "http://example.com/","prefix::local",null,"INVALID_CHARACTER_ERR" Pass createDocument test: "http://example.com/","namespaceURI:{",null,"INVALID_CHARACTER_ERR" Pass createDocument test: "http://example.com/","namespaceURI:}",null,"INVALID_CHARACTER_ERR" Pass createDocument test: "http://example.com/","namespaceURI:~",null,"INVALID_CHARACTER_ERR" diff --git a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createElementNS.txt b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createElementNS.txt index 2b6ca6ec518..e30db6cb8b5 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createElementNS.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/Document-createElementNS.txt @@ -2,8 +2,7 @@ Harness status: OK Found 596 tests -584 Pass -12 Fail +596 Pass Pass createElementNS test in HTML document: null,null,null Pass createElementNS test in XML document: null,null,null Pass createElementNS test in XHTML document: null,null,null @@ -145,9 +144,9 @@ Pass createElementNS test in XHTML document: undefined,"f:oo","NAMESPACE_ERR" Pass createElementNS test in HTML document: undefined,"foo:","INVALID_CHARACTER_ERR" Pass createElementNS test in XML document: undefined,"foo:","INVALID_CHARACTER_ERR" Pass createElementNS test in XHTML document: undefined,"foo:","INVALID_CHARACTER_ERR" -Fail createElementNS test in HTML document: undefined,"f::oo","INVALID_CHARACTER_ERR" -Fail createElementNS test in XML document: undefined,"f::oo","INVALID_CHARACTER_ERR" -Fail createElementNS test in XHTML document: undefined,"f::oo","INVALID_CHARACTER_ERR" +Pass createElementNS test in HTML document: undefined,"f::oo","INVALID_CHARACTER_ERR" +Pass createElementNS test in XML document: undefined,"f::oo","INVALID_CHARACTER_ERR" +Pass createElementNS test in XHTML document: undefined,"f::oo","INVALID_CHARACTER_ERR" Pass createElementNS test in HTML document: undefined,"xml",null Pass createElementNS test in XML document: undefined,"xml",null Pass createElementNS test in XHTML document: undefined,"xml",null @@ -196,15 +195,15 @@ Pass createElementNS test in XHTML document: "http://example.com/",":foo","INVAL Pass createElementNS test in HTML document: "http://example.com/","f:oo",null Pass createElementNS test in XML document: "http://example.com/","f:oo",null Pass createElementNS test in XHTML document: "http://example.com/","f:oo",null -Fail createElementNS test in HTML document: "http://example.com/","f:o:o",null -Fail createElementNS test in XML document: "http://example.com/","f:o:o",null -Fail createElementNS test in XHTML document: "http://example.com/","f:o:o",null +Pass createElementNS test in HTML document: "http://example.com/","f:o:o",null +Pass createElementNS test in XML document: "http://example.com/","f:o:o",null +Pass createElementNS test in XHTML document: "http://example.com/","f:o:o",null Pass createElementNS test in HTML document: "http://example.com/","foo:","INVALID_CHARACTER_ERR" Pass createElementNS test in XML document: "http://example.com/","foo:","INVALID_CHARACTER_ERR" Pass createElementNS test in XHTML document: "http://example.com/","foo:","INVALID_CHARACTER_ERR" -Fail createElementNS test in HTML document: "http://example.com/","f::oo","INVALID_CHARACTER_ERR" -Fail createElementNS test in XML document: "http://example.com/","f::oo","INVALID_CHARACTER_ERR" -Fail createElementNS test in XHTML document: "http://example.com/","f::oo","INVALID_CHARACTER_ERR" +Pass createElementNS test in HTML document: "http://example.com/","f::oo","INVALID_CHARACTER_ERR" +Pass createElementNS test in XML document: "http://example.com/","f::oo","INVALID_CHARACTER_ERR" +Pass createElementNS test in XHTML document: "http://example.com/","f::oo","INVALID_CHARACTER_ERR" Pass createElementNS test in HTML document: "http://example.com/","a:0","INVALID_CHARACTER_ERR" Pass createElementNS test in XML document: "http://example.com/","a:0","INVALID_CHARACTER_ERR" Pass createElementNS test in XHTML document: "http://example.com/","a:0","INVALID_CHARACTER_ERR" @@ -301,9 +300,9 @@ Pass createElementNS test in XHTML document: "http://example.com/","XMLNS:foo",n Pass createElementNS test in HTML document: "http://example.com/","xmlfoo:bar",null Pass createElementNS test in XML document: "http://example.com/","xmlfoo:bar",null Pass createElementNS test in XHTML document: "http://example.com/","xmlfoo:bar",null -Fail createElementNS test in HTML document: "http://example.com/","prefix::local","INVALID_CHARACTER_ERR" -Fail createElementNS test in XML document: "http://example.com/","prefix::local","INVALID_CHARACTER_ERR" -Fail createElementNS test in XHTML document: "http://example.com/","prefix::local","INVALID_CHARACTER_ERR" +Pass createElementNS test in HTML document: "http://example.com/","prefix::local","INVALID_CHARACTER_ERR" +Pass createElementNS test in XML document: "http://example.com/","prefix::local","INVALID_CHARACTER_ERR" +Pass createElementNS test in XHTML document: "http://example.com/","prefix::local","INVALID_CHARACTER_ERR" Pass createElementNS test in HTML document: "http://example.com/","namespaceURI:{","INVALID_CHARACTER_ERR" Pass createElementNS test in XML document: "http://example.com/","namespaceURI:{","INVALID_CHARACTER_ERR" Pass createElementNS test in XHTML document: "http://example.com/","namespaceURI:{","INVALID_CHARACTER_ERR"