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

Unified Diff: pkg/polymer/lib/boot.js

Issue 27246006: Small fix to boot.js so it can work with CSP if an existing html-import tag is (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/boot.js
diff --git a/pkg/polymer/lib/boot.js b/pkg/polymer/lib/boot.js
index 9b1eef8a94c768e9dda7557d235457a5b3b0c6ff..a65dd3e22eeb984e314ba450848052938eacccab 100644
--- a/pkg/polymer/lib/boot.js
+++ b/pkg/polymer/lib/boot.js
@@ -70,8 +70,23 @@
// Load HTML Imports:
var htmlImportsSrc = 'src="packages/html_import/html_import.min.js"';
- document.write('<script ' + htmlImportsSrc + '></script>');
+ var htmlImportsTag = '<script ' + htmlImportsSrc + '></script>';
var importScript = document.querySelector('script[' + htmlImportsSrc + ']');
+
+ if (!importScript) {
+ try {
+ document.write(htmlImportsTag);
+ importScript = document.querySelector('script[' + htmlImportsSrc + ']');
+ } catch (e) {
+ console.error(
+ "Failed to use document.write() to inject the HTML import " +
+ "polyfill.\nIf you are running a Chrome packaged app, " +
Jennifer Messerly 2013/10/15 17:59:21 nit: "If you are running a Chrome packaged app..."
Siggi Cherem (dart-lang) 2013/10/15 19:10:44 Done.
+ "try adding the following to your HTML's <head> BEFORE the " +
+ "line that includes polymer/boot.js:\n " + htmlImportsTag);
+ return;
+ }
+ }
+
importScript.addEventListener('load', function() {
// NOTE: this is from polymer/src/lib/dom.js
window.HTMLImports.importer.preloadSelectors +=
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698