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

Unified Diff: pkg/polymer/lib/src/build/import_inliner.dart

Issue 404623002: normalize url attributes on entry point elements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review updates Created 6 years, 5 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/.gitignore ('k') | pkg/polymer/test/build/import_inliner_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1b2e86acf364e9e1211e21911c926bb1cc8a061e 100644
--- a/pkg/polymer/lib/src/build/import_inliner.dart
+++ b/pkg/polymer/lib/src/build/import_inliner.dart
@@ -45,14 +45,16 @@ class _HtmlInliner extends PolymerTransformer {
seen.add(docId);
Document document;
- bool changed;
+ bool changed = false;
return readPrimaryAsHtml(transform).then((doc) {
document = doc;
+ changed = new _UrlNormalizer(transform, docId).visit(document) || changed;
+
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 +304,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 +326,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);
« no previous file with comments | « pkg/.gitignore ('k') | pkg/polymer/test/build/import_inliner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698