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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElement.cpp

Issue 2054433002: Implement "create an element" when sync for Custom Element V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-ce
Patch Set: Prefer ExceptionState over throw Created 4 years, 6 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/custom/CustomElement.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
index f1e231cb1aa15fc374b15bd984f335d3c4c34276..83d82d902f7e2f2e8a23ceab9852528288271a42 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
@@ -86,8 +86,28 @@ HTMLElement* CustomElement::createCustomElement(Document& document, const Atomic
flags);
}
+HTMLElement* CustomElement::createCustomElement(Document& document, const AtomicString& localName, CreateElementFlags flags,
+ ExceptionState& exceptionState)
+{
+ return createCustomElement(document,
+ QualifiedName(nullAtom, localName, HTMLNames::xhtmlNamespaceURI),
+ flags, exceptionState);
+}
+
HTMLElement* CustomElement::createCustomElement(Document& document, const QualifiedName& tagName, CreateElementFlags flags)
{
+ return createCustomElement(document, tagName, flags, nullptr);
+}
+
+HTMLElement* CustomElement::createCustomElement(Document& document, const QualifiedName& tagName, CreateElementFlags flags,
+ ExceptionState& exceptionState)
+{
+ return createCustomElement(document, tagName, flags, &exceptionState);
+}
+
+HTMLElement* CustomElement::createCustomElement(Document& document, const QualifiedName& tagName, CreateElementFlags flags,
+ ExceptionState* exceptionState)
+{
DCHECK(shouldCreateCustomElement(document, tagName));
// To create an element:
@@ -100,7 +120,16 @@ HTMLElement* CustomElement::createCustomElement(Document& document, const Qualif
if (flags & AsynchronousCustomElements)
return createCustomElementAsync(document, *definition, tagName);
- // TODO(kojii): Synchronous mode implementation coming after async.
+ // When invoked from "create an element for a token":
+ // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token
+ // 7. If this step throws an exception, then report the exception,
+ // and let element be instead a new element that implements
+ // HTMLUnknownElement.
+ if (!exceptionState)
+ return definition->createElementByRunningConstructor(document, tagName);
+
+ // 6.1. If the synchronous custom elements flag is set:
+ return definition->createElementByRunningConstructor(document, tagName, *exceptionState);
}
}

Powered by Google App Engine
This is Rietveld 408576698