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

Unified Diff: pkg/polymer/lib/src/transform/code_extractor.dart

Issue 23011045: Declare the sequence of phases for the full polymer transform and add tests for (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « pkg/polymer/lib/src/transform.dart ('k') | pkg/polymer/lib/src/transform/script_compactor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « pkg/polymer/lib/src/transform.dart ('k') | pkg/polymer/lib/src/transform/script_compactor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698