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

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

Issue 2477713003: Custom Elements: Check Definition in createElement, Create Customized Built-in Elements Sync (Closed)
Patch Set: Made changes Created 4 years, 1 month 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 e21ad5c22d40338d8f947db3e5b1a31f5ea58503..feee47864b93af6d63aa3e82b5d59dc5ddf30866 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -44,6 +44,7 @@
#include "bindings/core/v8/V8PerIsolateData.h"
#include "bindings/core/v8/WindowProxy.h"
#include "core/HTMLElementFactory.h"
+#include "core/HTMLElementTypeHelpers.h"
#include "core/HTMLNames.h"
#include "core/SVGElementFactory.h"
#include "core/SVGNames.h"
@@ -713,6 +714,12 @@ String getTypeExtension(Document* document,
Element* Document::createElement(const AtomicString& localName,
const StringOrDictionary& stringOrOptions,
ExceptionState& exceptionState) {
+ const AtomicString& is =
+ getTypeExtension(this, stringOrOptions, exceptionState).isEmpty()
dominicc (has gone to gerrit) 2016/11/08 08:36:29 There should be a cheaper way to do this where you
+ ? AtomicString()
+ : AtomicString(
+ getTypeExtension(this, stringOrOptions, exceptionState));
+
if (!isValidName(localName)) {
exceptionState.throwDOMException(
InvalidCharacterError,
@@ -722,9 +729,14 @@ Element* Document::createElement(const AtomicString& localName,
Element* element;
- if (CustomElement::shouldCreateCustomElement(convertLocalName(localName))) {
+ bool shouldCreateBuiltin =
+ stringOrOptions.isDictionary() &&
+ RuntimeEnabledFeatures::customElementsBuiltinEnabled();
+
+ if (CustomElement::shouldCreateCustomElement(convertLocalName(localName)) ||
+ shouldCreateBuiltin) {
element = CustomElement::createCustomElementSync(
- *this, convertLocalName(localName));
+ *this, convertLocalName(localName), is);
} else if (V0CustomElement::isValidName(localName) && registrationContext()) {
element = registrationContext()->createCustomTagElement(
*this, QualifiedName(nullAtom, convertLocalName(localName),
@@ -735,11 +747,13 @@ Element* Document::createElement(const AtomicString& localName,
return nullptr;
}
- String typeExtention =
- getTypeExtension(this, stringOrOptions, exceptionState);
- if (!typeExtention.isEmpty()) {
- V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(
- element, AtomicString(typeExtention));
+ if (!is.isEmpty()) {
+ if (element->getCustomElementState() != CustomElementState::Custom) {
+ V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(
+ element, is);
+ } else if (stringOrOptions.isDictionary()) {
+ element->setAttribute(HTMLNames::isAttr, is);
+ }
}
return element;

Powered by Google App Engine
This is Rietveld 408576698