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

Unified Diff: pkg/polymer/lib/src/mirror_loader.dart

Issue 662013004: fix duplicate script issue (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review updates Created 6 years, 2 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/build/messages.dart ('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/mirror_loader.dart
diff --git a/pkg/polymer/lib/src/mirror_loader.dart b/pkg/polymer/lib/src/mirror_loader.dart
index c0cea5c46aa11a15844976eb30e895880f332fe0..cd5bc8ffcb4ba3babf6b02837f4811a752716e17 100644
--- a/pkg/polymer/lib/src/mirror_loader.dart
+++ b/pkg/polymer/lib/src/mirror_loader.dart
@@ -65,22 +65,29 @@ List<Function> discoverInitializers(Iterable<String> librariesToLoad) {
/// called after all HTML imports are resolved. Polymer ensures this by asking
/// users to put their Dart script tags after all HTML imports (this is checked
/// by the linter, and Dartium will otherwise show an error message).
-List<_ScriptInfo> _discoverScripts(Document doc, String baseUri, [_State state]) {
+Iterable<_ScriptInfo> _discoverScripts(
+ Document doc, String baseUri, [_State state]) {
if (state == null) state = new _State();
if (doc == null) {
print('warning: $baseUri not found.');
- return state.scripts;
+ return state.scripts.values;
}
- if (!state.seen.add(doc)) return state.scripts;
+ if (!state.seen.add(doc)) return state.scripts.values;
for (var node in doc.querySelectorAll('script,link[rel="import"]')) {
if (node is LinkElement) {
_discoverScripts(node.import, node.href, state);
} else if (node is ScriptElement && node.type == 'application/dart') {
- state.scripts.add(_scriptInfoFor(node, baseUri));
+ var info = _scriptInfoFor(node, baseUri);
+ if (state.scripts.containsKey(info.resolvedUrl)) {
+ print('warning: Script `${info.resolvedUrl}` included more than once. '
+ 'See http://goo.gl/5HPeuP#polymer_44 for more details.');
+ } else {
+ state.scripts[info.resolvedUrl] = info;
+ }
}
}
- return state.scripts;
+ return state.scripts.values;
}
/// Internal state used in [_discoverScripts].
@@ -89,7 +96,7 @@ class _State {
final Set<Document> seen = new Set();
/// Scripts that have been discovered, in tree order.
- final List<_ScriptInfo> scripts = [];
+ final LinkedHashMap<String, _ScriptInfo> scripts = {};
}
/// Holds information about a Dart script tag.
« no previous file with comments | « pkg/polymer/lib/src/build/messages.dart ('k') | pkg/polymer/test/build/import_inliner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698