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

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: createElement - sync 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 7755997f837a5574ff44bf827390c9cfa208929d..9d214c3afe4173b819ddf1cb8a2ff0be65df21d4 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"
@@ -712,6 +713,12 @@ String getTypeExtension(Document* document,
Element* Document::createElement(const AtomicString& localName,
const StringOrDictionary& stringOrOptions,
ExceptionState& exceptionState) {
+ const AtomicString& is =
+ getTypeExtension(this, stringOrOptions, exceptionState).isEmpty()
+ ? AtomicString()
+ : AtomicString(
+ getTypeExtension(this, stringOrOptions, exceptionState));
+
if (!isValidName(localName)) {
exceptionState.throwDOMException(
InvalidCharacterError,
@@ -721,9 +728,16 @@ Element* Document::createElement(const AtomicString& localName,
Element* element;
- if (CustomElement::shouldCreateCustomElement(convertLocalName(localName))) {
- element = CustomElement::createCustomElementSync(
- *this, convertLocalName(localName));
+ int builtin = 0;
dominicc (has gone to gerrit) 2016/11/07 01:59:00 Use bool, not int, for true/false values. C++ 'hel
+ if (RuntimeEnabledFeatures::customElementsBuiltinEnabled() &&
+ stringOrOptions.isDictionary()) {
+ builtin = 1;
+ }
+
+ if (CustomElement::shouldCreateCustomElement(convertLocalName(localName)) ||
dominicc (has gone to gerrit) 2016/11/07 01:58:59 The createElement spec case-converts names sometim
+ builtin) {
+ return CustomElement::createCustomElementSync(
+ *this, convertLocalName(localName), is);
} else if (V0CustomElement::isValidName(localName) && registrationContext()) {
element = registrationContext()->createCustomTagElement(
*this, QualifiedName(nullAtom, convertLocalName(localName),
@@ -734,11 +748,9 @@ 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()) {
+ V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element,
+ is);
}
return element;

Powered by Google App Engine
This is Rietveld 408576698