Chromium Code Reviews| Index: pkg/polymer/lib/src/build/import_inliner.dart |
| diff --git a/pkg/polymer/lib/src/build/import_inliner.dart b/pkg/polymer/lib/src/build/import_inliner.dart |
| index b48dd6f8823b385b616b5563006245ee3d810b1c..6c75bc0e5b80238467a574c7506a04d523ee4cd9 100644 |
| --- a/pkg/polymer/lib/src/build/import_inliner.dart |
| +++ b/pkg/polymer/lib/src/build/import_inliner.dart |
| @@ -45,14 +45,17 @@ class _HtmlInliner extends PolymerTransformer { |
| seen.add(docId); |
| Document document; |
| - bool changed; |
| + bool changed = false; |
| return readPrimaryAsHtml(transform).then((doc) { |
| document = doc; |
| + return new _UrlNormalizer(transform, docId).visit(document); |
| + }).then((urlsNormalized) { |
|
Siggi Cherem (dart-lang)
2014/07/17 22:31:50
since the normalization is synchronous, we can jus
jakemac
2014/07/17 22:36:40
Done.
|
| + changed = changed || urlsNormalized; |
| experimentalBootstrap = document.querySelectorAll('link').any((link) => |
| link.attributes['rel'] == 'import' && |
| link.attributes['href'] == POLYMER_EXPERIMENTAL_HTML); |
| - changed = _extractScripts(document); |
| + changed = _extractScripts(document) || changed; |
| return _visitImports(document); |
| }).then((importsFound) { |
| changed = changed || importsFound; |
| @@ -302,11 +305,19 @@ class _UrlNormalizer extends TreeVisitor { |
| /// This should just be some arbitrary # of ../'s. |
| final String topLevelPath; |
| + /// Whether or not the normalizer has changed something in the tree. |
| + bool changed = false; |
| + |
| _UrlNormalizer(transform, this.sourceId) |
| : transform = transform, |
| topLevelPath = |
| '../' * (transform.primaryInput.id.path.split('/').length - 2); |
| + visit(Element node) { |
| + super.visit(node); |
| + return changed; |
| + } |
| + |
| visitElement(Element node) { |
| // TODO(jakemac): Support custom elements that extend html elements which |
| // have url-like attributes. This probably means keeping a list of which |
| @@ -316,20 +327,23 @@ class _UrlNormalizer extends TreeVisitor { |
| if (_urlAttributes.contains(name)) { |
| if (value != '' && !value.trim().startsWith('{{')) { |
| node.attributes[name] = _newUrl(value, node.sourceSpan); |
| + changed = changed || value != node.attributes[name]; |
| } |
| } |
| }); |
| } |
| if (node.localName == 'style') { |
| node.text = visitCss(node.text); |
| + changed = true; |
| } else if (node.localName == 'script' && |
| node.attributes['type'] == TYPE_DART && |
| !node.attributes.containsKey('src')) { |
| // TODO(jmesserly): we might need to visit JS too to handle ES Harmony |
| // modules. |
| node.text = visitInlineDart(node.text); |
| + changed = true; |
| } |
| - super.visitElement(node); |
| + return super.visitElement(node); |
| } |
| static final _URL = new RegExp(r'url\(([^)]*)\)', multiLine: true); |