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

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: add warnings and fix dynamic version 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
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..257d4e2e6902629f22a13dff4d8de7e05621c102 100644
--- a/pkg/polymer/lib/src/mirror_loader.dart
+++ b/pkg/polymer/lib/src/mirror_loader.dart
@@ -65,7 +65,8 @@ 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]) {
+List<_ScriptInfo> _discoverScripts(
+ Document doc, String baseUri, [_State state]) {
if (state == null) state = new _State();
if (doc == null) {
print('warning: $baseUri not found.');
@@ -77,7 +78,13 @@ List<_ScriptInfo> _discoverScripts(Document doc, String baseUri, [_State state])
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);
+ // Bail and warn if this script has already been seen.
+ if (state.scripts.any((s) => s.resolvedUrl == info.resolvedUrl)) {
Siggi Cherem (dart-lang) 2014/10/21 17:06:03 similarly here, let's avoid the linear lookup. One
jakemac 2014/10/21 18:14:01 Done.
+ print('warning: script `${info.resolvedUrl}` included more than once.');
Siggi Cherem (dart-lang) 2014/10/21 17:06:03 consider including the short link to the details h
jakemac 2014/10/21 18:14:01 Done.
+ continue;
+ };
+ state.scripts.add(info);
}
}
return state.scripts;

Powered by Google App Engine
This is Rietveld 408576698