| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Common methods used by transfomers. | 5 /// Common methods used by transfomers. |
| 6 library polymer.src.build.common; | 6 library polymer.src.build.common; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:math' show min, max; | 9 import 'dart:math' show min, max; |
| 10 | 10 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 var scanner = new Scanner(null, reader, errorListener); | 181 var scanner = new Scanner(null, reader, errorListener); |
| 182 var token = scanner.tokenize(); | 182 var token = scanner.tokenize(); |
| 183 var parser = new Parser(null, errorListener); | 183 var parser = new Parser(null, errorListener); |
| 184 return parser.parseCompilationUnit(token); | 184 return parser.parseCompilationUnit(token); |
| 185 } | 185 } |
| 186 | 186 |
| 187 class _ErrorCollector extends AnalysisErrorListener { | 187 class _ErrorCollector extends AnalysisErrorListener { |
| 188 final errors = <AnalysisError>[]; | 188 final errors = <AnalysisError>[]; |
| 189 onError(error) => errors.add(error); | 189 onError(error) => errors.add(error); |
| 190 } | 190 } |
| 191 |
| 192 /// These names have meaning in SVG or MathML, so they aren't allowed as custom |
| 193 /// tags. See [isCustomTagName]. |
| 194 const invalidTagNames = const { |
| 195 'annotation-xml': '', |
| 196 'color-profile': '', |
| 197 'font-face': '', |
| 198 'font-face-src': '', |
| 199 'font-face-uri': '', |
| 200 'font-face-format': '', |
| 201 'font-face-name': '', |
| 202 'missing-glyph': '', |
| 203 }; |
| 204 |
| 205 /// Returns true if this is a valid custom element name. See: |
| 206 /// <http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type> |
| 207 bool isCustomTagName(String name) { |
| 208 if (name == null || !name.contains('-')) return false; |
| 209 return !invalidTagNames.containsKey(name); |
| 210 } |
| OLD | NEW |