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

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

Issue 1914383002: Implement CustomElement::isValidName() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@PCENChar
Patch Set: Rebase Created 4 years, 8 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 90569898c64ffbe0506a70a3a883229adfe56866..fb55576c5c0db3774ea8c68b6b824ebb26f2300c 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
@@ -5,10 +5,11 @@
#include "core/dom/custom/CustomElement.h"
#include "platform/text/Character.h"
+#include "wtf/text/AtomicStringHash.h"
namespace blink {
-bool CustomElement::isPotentialCustomElementName(const AtomicString& name)
+bool CustomElement::isValidName(const AtomicString& name)
{
if (!name.length() || name[0] < 'a' || name[0] > 'z')
return false;
@@ -25,7 +26,23 @@ bool CustomElement::isPotentialCustomElementName(const AtomicString& name)
else if (!Character::isPotentialCustomElementNameChar(ch))
return false;
}
- return hasHyphens;
+ if (!hasHyphens)
+ return false;
+
+ // https://html.spec.whatwg.org/multipage/scripting.html#valid-custom-element-name
+ DEFINE_STATIC_LOCAL(HashSet<AtomicString>, hyphenContainingElementNames, ());
+ if (hyphenContainingElementNames.isEmpty()) {
+ hyphenContainingElementNames.add("annotation-xml");
+ hyphenContainingElementNames.add("color-profile");
+ hyphenContainingElementNames.add("font-face");
+ hyphenContainingElementNames.add("font-face-src");
+ hyphenContainingElementNames.add("font-face-uri");
+ hyphenContainingElementNames.add("font-face-format");
+ hyphenContainingElementNames.add("font-face-name");
+ hyphenContainingElementNames.add("missing-glyph");
+ }
+
+ return !hyphenContainingElementNames.contains(name);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698