Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..90569898c64ffbe0506a70a3a883229adfe56866 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.cpp |
| @@ -0,0 +1,31 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/dom/custom/CustomElement.h" |
| + |
| +#include "platform/text/Character.h" |
| + |
| +namespace blink { |
| + |
| +bool CustomElement::isPotentialCustomElementName(const AtomicString& name) |
| +{ |
| + if (!name.length() || name[0] < 'a' || name[0] > 'z') |
| + return false; |
| + |
| + bool hasHyphens = false; |
| + for (size_t i = 1; i < name.length(); ) { |
| + UChar32 ch; |
| + if (name.is8Bit()) |
| + ch = name[i++]; |
| + else |
| + U16_NEXT(name.characters16(), i, name.length(), ch); |
| + if (ch == '-') |
|
dominicc (has gone to gerrit)
2016/04/27 01:42:14
Maybe hasHyphens |= ch == '-' is more succinct?
kojii
2016/04/27 03:52:13
We don't have to call Character::isPotentialCustom
|
| + hasHyphens = true; |
| + else if (!Character::isPotentialCustomElementNameChar(ch)) |
| + return false; |
| + } |
| + return hasHyphens; |
|
dominicc (has gone to gerrit)
2016/04/27 01:42:14
This also needs to filter out
annotation-xml
colo
kojii
2016/04/27 03:52:13
Agreed. If I read the spec correctly,
valid cust
|
| +} |
| + |
| +} // namespace blink |