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

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: 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..eebcb2d9f9ec13d9c35fa040d817c2d1195b30bb 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp
@@ -5,9 +5,31 @@
#include "core/dom/custom/CustomElement.h"
#include "platform/text/Character.h"
+#include "wtf/text/AtomicStringHash.h"
namespace blink {
+bool CustomElement::isValidName(const AtomicString& name)
+{
+ if (!isPotentialCustomElementName(name))
+ 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);
+}
+
bool CustomElement::isPotentialCustomElementName(const AtomicString& name)
{
if (!name.length() || name[0] < 'a' || name[0] > 'z')

Powered by Google App Engine
This is Rietveld 408576698