From 28db57f345bc05cb8582d9e3efdeb43ba3cc39bb Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 12 Jun 2015 07:57:50 -0700 Subject: [PATCH] don't inline type='css' imports --- CHANGELOG.md | 3 +++ lib/build/import_crawler.dart | 4 +++- lib/build/import_inliner.dart | 5 ++++- lib/build/test_compatibility.dart | 4 ++-- pubspec.yaml | 2 +- test/build/test_compatibility_test.dart | 2 -- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c70e03..b42c844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +#### 0.11.4+2 + * Don't inline type="css" imports. + #### 0.11.4+1 * Fix erroneous messages about invalid package paths in html imports [72](https://github.com/dart-lang/polymer-dart/issues/72). diff --git a/lib/build/import_crawler.dart b/lib/build/import_crawler.dart index 641a3bc..0053a18 100644 --- a/lib/build/import_crawler.dart +++ b/lib/build/import_crawler.dart @@ -54,7 +54,9 @@ class ImportCrawler { seen.add(assetId); Future crawlImports(Document document) { - var imports = document.querySelectorAll('link[rel="import"]'); + var imports = document + .querySelectorAll('link[rel="import"]') + .where((import) => import.attributes['type'] != 'css'); var done = Future.forEach(imports, (i) => doCrawl(_importId(assetId, i), import: i, from: assetId)); diff --git a/lib/build/import_inliner.dart b/lib/build/import_inliner.dart index 787332a..1f562a7 100644 --- a/lib/build/import_inliner.dart +++ b/lib/build/import_inliner.dart @@ -71,13 +71,16 @@ class ImportInliner { if (imports.length > 1) { _inlineImports(primaryDocument, imports); } else if (!changed && - primaryDocument.querySelectorAll('link[rel="import"]').length == 0) { + primaryDocument.querySelectorAll('link[rel="import"]').where( + (import) => import.attributes['type'] != 'css').length == + 0) { // If there were no url changes and no imports, then we are done. return; } primaryDocument .querySelectorAll('link[rel="import"]') + .where((import) => import.attributes['type'] != 'css') .forEach((element) => element.remove()); transform.addOutput( diff --git a/lib/build/test_compatibility.dart b/lib/build/test_compatibility.dart index 4687502..a25d965 100644 --- a/lib/build/test_compatibility.dart +++ b/lib/build/test_compatibility.dart @@ -51,8 +51,8 @@ class RewriteScriptToXDartTest extends _EntryPointOnlyTransformer { Future apply(Transform transform) { return transform.primaryInput.readAsString().then((String html) { var doc = parse(html); - var scripts = doc.querySelectorAll( - 'script[type="application/dart"][$testAttribute]'); + var scripts = doc + .querySelectorAll('script[type="application/dart"][$testAttribute]'); for (var tag in scripts) { tag.replaceWith(new Element.tag('link') ..attributes['rel'] = 'x-dart-test' diff --git a/pubspec.yaml b/pubspec.yaml index 9ac32b2..145ea88 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: web_components -version: 0.11.4+1 +version: 0.11.4+2 author: Polymer.dart Authors homepage: https://www.dartlang.org/polymer-dart/ description: > diff --git a/test/build/test_compatibility_test.dart b/test/build/test_compatibility_test.dart index 981cf26..25272ac 100644 --- a/test/build/test_compatibility_test.dart +++ b/test/build/test_compatibility_test.dart @@ -35,7 +35,6 @@ main() { ''', }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); - testPhases('can rewrite script tags to x-dart-test link tags', [[end]], { 'a|test/index.html': ''' @@ -57,7 +56,6 @@ main() { ''', }, [], StringFormatter.noNewlinesOrSurroundingWhitespace); - testPhases('restores original application at the end', [[start], [end]], { 'a|test/index.html': '''