Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2442223003: Make createElement tag name case handling consistent for custom elements (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 26ac4eb144ec0e01fc628d9693323e151f0418f8..c3984a261c3af6d4f423e2278e445b995b332e58 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -642,6 +642,7 @@ AtomicString Document::convertLocalName(const AtomicString& name) {
return isHTMLDocument() ? name.lower() : name;
}
+// https://dom.spec.whatwg.org/#dom-document-createelement
Element* Document::createElement(const AtomicString& name,
ExceptionState& exceptionState) {
if (!isValidName(name)) {
@@ -652,11 +653,14 @@ Element* Document::createElement(const AtomicString& name,
}
if (isXHTMLDocument() || isHTMLDocument()) {
- if (CustomElement::shouldCreateCustomElement(name))
- return CustomElement::createCustomElementSync(*this, name,
+ // 2. If the context object is an HTML document, let localName be
+ // converted to ASCII lowercase.
+ AtomicString localName = convertLocalName(name);
+ if (CustomElement::shouldCreateCustomElement(localName))
+ return CustomElement::createCustomElementSync(*this, localName,
exceptionState);
- return HTMLElementFactory::createHTMLElement(convertLocalName(name), *this,
- 0, CreatedByCreateElement);
+ return HTMLElementFactory::createHTMLElement(localName, *this, 0,
+ CreatedByCreateElement);
}
return Element::create(QualifiedName(nullAtom, name, nullAtom), this);
@@ -674,9 +678,9 @@ Element* Document::createElement(const AtomicString& localName,
Element* element;
- if (CustomElement::shouldCreateCustomElement(localName)) {
- element = CustomElement::createCustomElementSync(*this, localName,
- exceptionState);
+ if (CustomElement::shouldCreateCustomElement(convertLocalName(localName))) {
+ element = CustomElement::createCustomElementSync(
+ *this, convertLocalName(localName), exceptionState);
} else if (V0CustomElement::isValidName(localName) && registrationContext()) {
element = registrationContext()->createCustomTagElement(
*this, QualifiedName(nullAtom, convertLocalName(localName),
« no previous file with comments | « third_party/WebKit/Source/core/BUILD.gn ('k') | third_party/WebKit/Source/core/dom/custom/CustomElementRegistryTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698