diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index f1ab4515f0a7..c9ba3ee1ff20 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -688,10 +688,8 @@ CustomElementRegistry::Define(const nsAString& aName, * 2. If name is not a valid custom element name, then throw a "SyntaxError" * DOMException and abort these steps. */ - nsIDocument* doc = mWindow->GetExtantDoc(); - uint32_t nameSpaceID = doc ? doc->GetDefaultNamespaceID() : kNameSpaceID_XHTML; RefPtr nameAtom(NS_Atomize(aName)); - if (!nsContentUtils::IsCustomElementName(nameAtom, nameSpaceID)) { + if (!nsContentUtils::IsCustomElementName(nameAtom)) { aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); return; } @@ -733,7 +731,7 @@ CustomElementRegistry::Define(const nsAString& aName, nsAutoString localName(aName); if (aOptions.mExtends.WasPassed()) { RefPtr extendsAtom(NS_Atomize(aOptions.mExtends.Value())); - if (nsContentUtils::IsCustomElementName(extendsAtom, nameSpaceID)) { + if (nsContentUtils::IsCustomElementName(extendsAtom)) { aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); return; } @@ -973,9 +971,7 @@ CustomElementRegistry::WhenDefined(const nsAString& aName, ErrorResult& aRv) } RefPtr nameAtom(NS_Atomize(aName)); - nsIDocument* doc = mWindow->GetExtantDoc(); - uint32_t nameSpaceID = doc ? doc->GetDefaultNamespaceID() : kNameSpaceID_XHTML; - if (!nsContentUtils::IsCustomElementName(nameAtom, nameSpaceID)) { + if (!nsContentUtils::IsCustomElementName(nameAtom)) { promise->MaybeReject(NS_ERROR_DOM_SYNTAX_ERR); return promise.forget(); } diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 3ecff81743e2..485f6841bf67 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1196,7 +1196,7 @@ Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError) * then throw a "NotSupportedError" DOMException. */ nsAtom* nameAtom = NodeInfo()->NameAtom(); - if (!(nsContentUtils::IsCustomElementName(nameAtom, NodeInfo()->NamespaceID()) || + if (!(nsContentUtils::IsCustomElementName(nameAtom) || nameAtom == nsGkAtoms::article || nameAtom == nsGkAtoms::aside || nameAtom == nsGkAtoms::blockquote || @@ -4304,7 +4304,7 @@ Element::SetCustomElementData(CustomElementData* aData) #if DEBUG nsAtom* name = NodeInfo()->NameAtom(); nsAtom* type = aData->GetCustomElementType(); - if (nsContentUtils::IsCustomElementName(name, NodeInfo()->NamespaceID())) { + if (nsContentUtils::IsCustomElementName(name)) { MOZ_ASSERT(type == name); } else { MOZ_ASSERT(type != name); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 090b0be55192..1415e5360c58 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -3194,13 +3194,8 @@ nsContentUtils::NewURIWithDocumentCharset(nsIURI** aResult, // static bool -nsContentUtils::IsCustomElementName(nsAtom* aName, uint32_t aNameSpaceID) +nsContentUtils::IsCustomElementName(nsAtom* aName) { - // Allow non-dashed names in XUL for XBL to Custom Element migrations. - if (aNameSpaceID == kNameSpaceID_XUL) { - return true; - } - // A valid custom element name is a sequence of characters name which // must match the PotentialCustomElementName production: // PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)* @@ -9985,9 +9980,9 @@ nsContentUtils::NewXULOrHTMLElement(Element** aResult, mozilla::dom::NodeInfo* a if (nodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) { tag = nsHTMLTags::CaseSensitiveAtomTagToId(name); isCustomElementName = (tag == eHTMLTag_userdefined && - nsContentUtils::IsCustomElementName(name, kNameSpaceID_XHTML)); + nsContentUtils::IsCustomElementName(name)); } else { - isCustomElementName = nsContentUtils::IsCustomElementName(name, kNameSpaceID_XUL); + isCustomElementName = nsContentUtils::IsCustomElementName(name); } RefPtr tagAtom = nodeInfo->NameAtom(); diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index c0ba691dd3e1..227e2697ad06 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -710,7 +710,7 @@ public: * Returns true if |aName| is a valid name to be registered via * customElements.define. */ - static bool IsCustomElementName(nsAtom* aName, uint32_t aNameSpaceID); + static bool IsCustomElementName(nsAtom* aName); static nsresult CheckQName(const nsAString& aQualifiedName, bool aNamespaceAware = true, diff --git a/dom/tests/mochitest/webcomponents/test_xul_custom_element.xul b/dom/tests/mochitest/webcomponents/test_xul_custom_element.xul index 179779d1e555..5b33116f7f4c 100644 --- a/dom/tests/mochitest/webcomponents/test_xul_custom_element.xul +++ b/dom/tests/mochitest/webcomponents/test_xul_custom_element.xul @@ -26,9 +26,6 @@ customElements.define("test-custom-element", TestCustomElement); - class TestWithoutDash extends XULElement { } - customElements.define("testwithoutdash", TestWithoutDash); - function runTest() { const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; @@ -56,9 +53,6 @@ "Parser should have instantiated the custom element."); ok(element4 instanceof TestCustomElement, "Should be an instance of TestCustomElement"); - let element5 = document.getElementById("element5"); - ok(element5 instanceof TestWithoutDash, "Should be an instance of TestWithoutDash"); - SimpleTest.finish(); } ]]> @@ -68,7 +62,6 @@