Chromium Code Reviews| Index: pkg/polymer/lib/src/transform/code_extractor.dart |
| diff --git a/pkg/polymer/lib/src/transform/code_extractor.dart b/pkg/polymer/lib/src/transform/code_extractor.dart |
| index 5f7058f01974f4dc335fbe5a05e797e577f45925..61fd2c6db382f73453d9d45a123f38e84a99bc83 100644 |
| --- a/pkg/polymer/lib/src/transform/code_extractor.dart |
| +++ b/pkg/polymer/lib/src/transform/code_extractor.dart |
| @@ -26,18 +26,28 @@ class InlineCodeExtractor extends Transformer { |
| var document = parseHtml(content, inputId.path, transform.logger); |
| int count = 0; |
| for (var tag in document.queryAll('script')) { |
| - if (tag.attributes['type'] == 'application/dart' && |
| - !tag.attributes.containsKey('src')) { |
| - // TODO(sigmund): should we automatically include a library directive |
| - // if it doesn't have one? |
| - var filename = path.url.basename(inputId.path); |
| - tag.attributes['src'] = '$filename.$count.dart'; |
| - var textContent = tag.nodes.first; |
| - var id = inputId.addExtension('.$count.dart'); |
| - transform.addOutput(new Asset.fromString(id, textContent.value)); |
| - textContent.remove(); |
| + // Only process tags that have inline Dart code |
| + if (tag.attributes['type'] != 'application/dart' || |
| + tag.attributes.containsKey('src')) { |
| + continue; |
| + } |
| + |
| + // Remove empty tags |
| + if (tag.nodes.length == 0) { |
| + tag.remove(); |
| count++; |
|
Jennifer Messerly
2013/08/23 01:23:11
instead of count, a boolean "htmlChanged" might be
Siggi Cherem (dart-lang)
2013/08/23 01:45:28
Done.
|
| + continue; |
| } |
| + |
| + // TODO(sigmund): should we automatically include a library directive |
| + // if it doesn't have one? |
| + var filename = path.url.basename(inputId.path); |
| + tag.attributes['src'] = '$filename.$count.dart'; |
|
Jennifer Messerly
2013/08/23 01:23:11
I forgot the outcome of previous CL discussion, sh
Siggi Cherem (dart-lang)
2013/08/23 01:45:28
Added TODO. Yeah, we weren't sure how necessary it
|
| + var textContent = tag.nodes.first; |
| + var id = inputId.addExtension('.$count.dart'); |
| + transform.addOutput(new Asset.fromString(id, textContent.value)); |
| + textContent.remove(); |
| + count++; |
| } |
| transform.addOutput(new Asset.fromString(inputId, |
| count == 0 ? content : document.outerHtml)); |