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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This script dynamically prepares a set of files to run polymer.dart. It uses 5 // This script dynamically prepares a set of files to run polymer.dart. It uses
6 // the html_import polyfill to search for all imported files, then 6 // the html_import polyfill to search for all imported files, then
7 // it inlines all <polymer-element> definitions on the top-level page (needed by 7 // it inlines all <polymer-element> definitions on the top-level page (needed by
8 // registerPolymerElement), and it removes script tags that appear inside 8 // registerPolymerElement), and it removes script tags that appear inside
9 // those tags. It finally rewrites the main entrypoint to call an initialization 9 // those tags. It finally rewrites the main entrypoint to call an initialization
10 // function on each of the declared <polymer-elements>. 10 // function on each of the declared <polymer-elements>.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 var dartJSQuery = 'script[src="packages/browser/dart.js"]'; 63 var dartJSQuery = 'script[src="packages/browser/dart.js"]';
64 if (!!document.querySelector(dartJSQuery)) { 64 if (!!document.querySelector(dartJSQuery)) {
65 console.error('Error: found "packages/browser/dart.js" in the ' + 65 console.error('Error: found "packages/browser/dart.js" in the ' +
66 'page. Please remove it. When using polymer\'s "boot.js", ' + 66 'page. Please remove it. When using polymer\'s "boot.js", ' +
67 'you can\'t use "dart.js".'); 67 'you can\'t use "dart.js".');
68 } 68 }
69 }); 69 });
70 70
71 // Load HTML Imports: 71 // Load HTML Imports:
72 var htmlImportsSrc = 'src="packages/html_import/html_import.min.js"'; 72 var htmlImportsSrc = 'src="packages/html_import/html_import.min.js"';
73 document.write('<script ' + htmlImportsSrc + '></script>'); 73 var htmlImportsTag = '<script ' + htmlImportsSrc + '></script>';
74 var importScript = document.querySelector('script[' + htmlImportsSrc + ']'); 74 var importScript = document.querySelector('script[' + htmlImportsSrc + ']');
75
76 if (!importScript) {
77 try {
78 document.write(htmlImportsTag);
79 importScript = document.querySelector('script[' + htmlImportsSrc + ']');
80 } catch (e) {
81 console.error(
82 "Failed to use document.write() to inject the HTML import " +
83 "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.
84 "try adding the following to your HTML's <head> BEFORE the " +
85 "line that includes polymer/boot.js:\n " + htmlImportsTag);
86 return;
87 }
88 }
89
75 importScript.addEventListener('load', function() { 90 importScript.addEventListener('load', function() {
76 // NOTE: this is from polymer/src/lib/dom.js 91 // NOTE: this is from polymer/src/lib/dom.js
77 window.HTMLImports.importer.preloadSelectors += 92 window.HTMLImports.importer.preloadSelectors +=
78 ', polymer-element link[rel=stylesheet]'; 93 ', polymer-element link[rel=stylesheet]';
79 }); 94 });
80 95
81 // TODO(jmesserly): we need this in deploy tool too. 96 // TODO(jmesserly): we need this in deploy tool too.
82 // NOTE: this is from polymer/src/boot.js: 97 // NOTE: this is from polymer/src/boot.js:
83 // FOUC prevention tactic 98 // FOUC prevention tactic
84 var style = document.createElement('style'); 99 var style = document.createElement('style');
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 alreadyRan = true; 200 alreadyRan = true;
186 var ref = document.body.children[0]; 201 var ref = document.body.children[0];
187 inlinePolymerElements(document, ref); 202 inlinePolymerElements(document, ref);
188 mergeScripts(); 203 mergeScripts();
189 if (!navigator.webkitStartDart()) { 204 if (!navigator.webkitStartDart()) {
190 document.body.innerHTML = 'This build has expired. Please download a ' + 205 document.body.innerHTML = 'This build has expired. Please download a ' +
191 'new Dartium at http://www.dartlang.org/dartium/index.html'; 206 'new Dartium at http://www.dartlang.org/dartium/index.html';
192 } 207 }
193 }); 208 });
194 })(); 209 })();
OLDNEW
« 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