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

Unified Diff: pkg/polymer/lib/src/build/linter.dart

Issue 211393006: Enables codegen support in polymer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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: pkg/polymer/lib/src/build/linter.dart
diff --git a/pkg/polymer/lib/src/build/linter.dart b/pkg/polymer/lib/src/build/linter.dart
index df3331894f2c75ef5e23101a4813aaec30335ca3..ecf63e489dcf39c3e7ba90517a44531e2a437a52 100644
--- a/pkg/polymer/lib/src/build/linter.dart
+++ b/pkg/polymer/lib/src/build/linter.dart
@@ -214,14 +214,14 @@ class _LinterVisitor extends TreeVisitor {
_logger.error('Missing tag name of the custom element. Please include an '
'attribute like \'name="your-tag-name"\'.',
span: node.sourceSpan);
- } else if (!_isCustomTag(tagName)) {
+ } else if (!isCustomTagName(tagName)) {
_logger.error('Invalid name "$tagName". Custom element names must have '
'at least one dash and can\'t be any of the following names: '
- '${_invalidTagNames.keys.join(", ")}.',
+ '${invalidTagNames.keys.join(", ")}.',
span: node.sourceSpan);
}
- if (_elements[extendsTag] == null && _isCustomTag(extendsTag)) {
+ if (_elements[extendsTag] == null && isCustomTagName(extendsTag)) {
_logger.warning('custom element with name "$extendsTag" not found.',
span: node.sourceSpan);
}
@@ -232,10 +232,8 @@ class _LinterVisitor extends TreeVisitor {
// names='a b c' or names='a,b,c'
// record each name for publishing
- for (var attr in attrs.split(attrs.contains(',') ? ',' : ' ')) {
- // remove excess ws
- attr = attr.trim();
- if (!_validateCustomAttributeName(attr, attrsSpan)) break;
+ for (var attr in attrs.split(_ATTRIBUTES_REGEX)) {
+ if (!_validateCustomAttributeName(attr.trim(), attrsSpan)) break;
}
}
@@ -299,7 +297,7 @@ class _LinterVisitor extends TreeVisitor {
var nodeTag = node.localName;
var hasIsAttribute;
var customTagName;
- if (_isCustomTag(nodeTag)) {
+ if (isCustomTagName(nodeTag)) {
// <fancy-button>
customTagName = nodeTag;
hasIsAttribute = false;
@@ -387,27 +385,6 @@ class _LinterVisitor extends TreeVisitor {
}
}
-
-// These names have meaning in SVG or MathML, so they aren't allowed as custom
-// tags.
-var _invalidTagNames = const {
- 'annotation-xml': '',
- 'color-profile': '',
- 'font-face': '',
- 'font-face-src': '',
- 'font-face-uri': '',
- 'font-face-format': '',
- 'font-face-name': '',
- 'missing-glyph': '',
-};
-
-/// Returns true if this is a valid custom element name. See:
-/// <https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-custom-element-name>
-bool _isCustomTag(String name) {
- if (name == null || !name.contains('-')) return false;
- return !_invalidTagNames.containsKey(name);
-}
-
const String USE_INIT_DART =
'To run a polymer application, you need to call "initPolymer". You can '
'either include a generic script tag that does this for you:'
@@ -423,3 +400,5 @@ const String BOOT_JS_DEPRECATED =
'"package:polymer/init.dart";</script>\'. Additionally you need to '
'include: \'<script src="packages/browser/dart.js"></script>\' in the page '
'too. Make sure these script tags come after all HTML imports.';
+
+final _ATTRIBUTES_REGEX = new RegExp(r'\s|,');
Jennifer Messerly 2014/03/27 02:20:32 maybe comment that this is identical to lib/src/de
Siggi Cherem (dart-lang) 2014/03/28 01:04:26 Done. added the reference and shared this with the

Powered by Google App Engine
This is Rietveld 408576698