| 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 /** | 5 /** |
| 6 * Logic to validate that developers are correctly using Polymer constructs. | 6 * Logic to validate that developers are correctly using Polymer constructs. |
| 7 * This is mainly used to produce warnings for feedback in the editor. | 7 * This is mainly used to produce warnings for feedback in the editor. |
| 8 */ | 8 */ |
| 9 library polymer.src.build.linter; | 9 library polymer.src.build.linter; |
| 10 | 10 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // We normalize the map, so each element has a direct reference to any | 154 // We normalize the map, so each element has a direct reference to any |
| 155 // element it extends from. | 155 // element it extends from. |
| 156 for (var tag in _elements.values) { | 156 for (var tag in _elements.values) { |
| 157 var extendsTag = tag.extendsTag; | 157 var extendsTag = tag.extendsTag; |
| 158 if (extendsTag == null) continue; | 158 if (extendsTag == null) continue; |
| 159 tag.extendsType = _elements[extendsTag]; | 159 tag.extendsType = _elements[extendsTag]; |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 void visitElement(Element node) { | 163 void visitElement(Element node) { |
| 164 switch (node.tagName) { | 164 switch (node.localName) { |
| 165 case 'link': _validateLinkElement(node); break; | 165 case 'link': _validateLinkElement(node); break; |
| 166 case 'element': _validateElementElement(node); break; | 166 case 'element': _validateElementElement(node); break; |
| 167 case 'polymer-element': _validatePolymerElement(node); break; | 167 case 'polymer-element': _validatePolymerElement(node); break; |
| 168 case 'script': _validateScriptElement(node); break; | 168 case 'script': _validateScriptElement(node); break; |
| 169 default: | 169 default: |
| 170 _validateNormalElement(node); | 170 _validateNormalElement(node); |
| 171 super.visitElement(node); | 171 super.visitElement(node); |
| 172 break; | 172 break; |
| 173 } | 173 } |
| 174 } | 174 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 */ | 320 */ |
| 321 void _validateNormalElement(Element node) { | 321 void _validateNormalElement(Element node) { |
| 322 // Event handlers only allowed inside polymer-elements | 322 // Event handlers only allowed inside polymer-elements |
| 323 node.attributes.forEach((name, value) { | 323 node.attributes.forEach((name, value) { |
| 324 if (name is String && name.startsWith('on')) { | 324 if (name is String && name.startsWith('on')) { |
| 325 _validateEventHandler(node, name, value); | 325 _validateEventHandler(node, name, value); |
| 326 } | 326 } |
| 327 }); | 327 }); |
| 328 | 328 |
| 329 // Validate uses of custom-tags | 329 // Validate uses of custom-tags |
| 330 var nodeTag = node.tagName; | 330 var nodeTag = node.localName; |
| 331 var hasIsAttribute; | 331 var hasIsAttribute; |
| 332 var customTagName; | 332 var customTagName; |
| 333 if (_isCustomTag(nodeTag)) { | 333 if (_isCustomTag(nodeTag)) { |
| 334 // <fancy-button> | 334 // <fancy-button> |
| 335 customTagName = nodeTag; | 335 customTagName = nodeTag; |
| 336 hasIsAttribute = false; | 336 hasIsAttribute = false; |
| 337 } else { | 337 } else { |
| 338 // <button is="fancy-button"> | 338 // <button is="fancy-button"> |
| 339 customTagName = node.attributes['is']; | 339 customTagName = node.attributes['is']; |
| 340 hasIsAttribute = true; | 340 hasIsAttribute = true; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 'Make sure the script tag is placed after all HTML imports.'; | 451 'Make sure the script tag is placed after all HTML imports.'; |
| 452 | 452 |
| 453 const String BOOT_JS_DEPRECATED = | 453 const String BOOT_JS_DEPRECATED = |
| 454 '"boot.js" is now deprecated. Instead, you can initialize your polymer ' | 454 '"boot.js" is now deprecated. Instead, you can initialize your polymer ' |
| 455 'application by calling "initPolymer()" in your main. If you don\'t have a ' | 455 'application by calling "initPolymer()" in your main. If you don\'t have a ' |
| 456 'main, then you can include our generic main by adding the following ' | 456 'main, then you can include our generic main by adding the following ' |
| 457 'script tag to your page: \'<script type="application/dart">export ' | 457 'script tag to your page: \'<script type="application/dart">export ' |
| 458 '"package:polymer/init.dart";</script>\'. Additionally you need to ' | 458 '"package:polymer/init.dart";</script>\'. Additionally you need to ' |
| 459 'include: \'<script src="packages/browser/dart.js"></script>\' in the page ' | 459 'include: \'<script src="packages/browser/dart.js"></script>\' in the page ' |
| 460 'too. Make sure these script tags come after all HTML imports.'; | 460 'too. Make sure these script tags come after all HTML imports.'; |
| OLD | NEW |