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

Unified Diff: pkg/polymer/lib/src/build/import_inliner.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/generated/messages.html ('k') | pkg/polymer/lib/src/build/messages.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 cf3b7d931e3c6ad44e52c0f90bc95b0d30f83bb2..ed7929b2d8ad72a3d54b3b29a6bfb6bc07e6ec90 100644
--- a/pkg/polymer/lib/src/build/import_inliner.dart
+++ b/pkg/polymer/lib/src/build/import_inliner.dart
@@ -7,6 +7,7 @@ library polymer.src.build.import_inliner;
import 'dart:async';
import 'dart:convert';
+import 'dart:collection' show LinkedHashSet;
import 'package:analyzer/analyzer.dart';
import 'package:analyzer/src/generated/ast.dart';
@@ -30,7 +31,7 @@ class _HtmlInliner extends PolymerTransformer {
final BuildLogger logger;
final AssetId docId;
final seen = new Set<AssetId>();
- final scriptIds = <AssetId>[];
+ final scriptIds = new LinkedHashSet<AssetId>();
final inlinedStylesheetIds = new Set<AssetId>();
final extractedFiles = new Set<AssetId>();
bool experimentalBootstrap = false;
@@ -94,7 +95,7 @@ class _HtmlInliner extends PolymerTransformer {
docId.addExtension('._data'),
JSON.encode({
'experimental_bootstrap': experimentalBootstrap,
- 'script_ids': scriptIds,
+ 'script_ids': scriptIds.toList(),
}, toEncodable: (id) => id.serialize())));
// Write out the logs collected by our [BuildLogger].
@@ -241,6 +242,13 @@ class _HtmlInliner extends PolymerTransformer {
var src = script.attributes['src'];
var srcId = uriToAssetId(docId, src, logger, script.sourceSpan);
+ // No duplicates allowed!
+ if (scriptIds.contains(srcId)) {
+ logger.warning(SCRIPT_INCLUDED_MORE_THAN_ONCE.create({'url': src}),
+ span: script.sourceSpan);
+ return true;
+ }
+
// We check for extractedFiles because 'hasInput' below is only true for
// assets that existed before this transformer runs (hasInput is false
// for files created by [_extractScripts]).
« no previous file with comments | « pkg/polymer/lib/src/build/generated/messages.html ('k') | pkg/polymer/lib/src/build/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698