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

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

Issue 2446903008: Custom Elements: Lookup custom element definition algorithm (Closed)
Patch Set: lookup custom element definition 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/custom/CustomElementRegistry.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp
index 0e703cad458ebf76c73dec97eca5604fcd7284f7..7ad996976d8534e102382e6414c79df8bf952aca 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp
@@ -194,16 +194,22 @@ ScriptValue CustomElementRegistry::get(const AtomicString& name) {
return definition->getConstructorForScript();
}
+// https://html.spec.whatwg.org/multipage/scripting.html#look-up-a-custom-element-definition
+// At this point, what the spec calls 'is' is 'name' from desc
CustomElementDefinition* CustomElementRegistry::definitionFor(
const CustomElementDescriptor& desc) const {
- CustomElementDefinition* definition = definitionForName(desc.name());
- if (!definition)
- return nullptr;
- // The definition for a customized built-in element, such as
- // <button is="my-button"> should not be provided for an
- // autonomous element, such as <my-button>, even though the
- // name "my-button" matches.
- return definition->descriptor() == desc ? definition : nullptr;
+ // 4. If there is a definition in registry with name equal to localName and
dominicc (has gone to gerrit) 2016/10/27 04:33:14 Try to write this with only one lookup with defini
+ // local name equal to localName, return that definition
+ CustomElementDefinition* definition = definitionForName(desc.localName());
+ if (definition and definition->descriptor().localName() == desc.localName())
+ return definition;
+ // 5. If there is a definition in registry with name equal to is and local
+ // name equal to localName, return that definition
+ definition = definitionForName(desc.name());
+ if (definition and definition->descriptor().localName() == desc.localName())
+ return definition;
+ // 6. Return null
+ return nullptr;
}
bool CustomElementRegistry::nameIsDefined(const AtomicString& name) const {

Powered by Google App Engine
This is Rietveld 408576698