| OLD | NEW |
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 (function() { | 50 (function() { |
| 51 // Only run in Dartium. | 51 // Only run in Dartium. |
| 52 if (!navigator.webkitStartDart) { | 52 if (!navigator.webkitStartDart) { |
| 53 // TODO(sigmund): rephrase when we split build.dart in two: analysis vs | 53 // TODO(sigmund): rephrase when we split build.dart in two: analysis vs |
| 54 // deploy pieces. | 54 // deploy pieces. |
| 55 console.warn('boot.js only works in Dartium. Run the build.dart' + | 55 console.warn('boot.js only works in Dartium. Run the build.dart' + |
| 56 ' tool to compile a depolyable JavaScript version') | 56 ' tool to compile a depolyable JavaScript version') |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Detect if dart.js was included in the page. We use DOMContentLoaded to make |
| 61 // sure we also check for occurrences after the current tag. |
| 62 window.addEventListener('DOMContentLoaded', function () { |
| 63 var dartJSQuery = 'script[src="packages/browser/dart.js"]'; |
| 64 if (!!document.querySelector(dartJSQuery)) { |
| 65 console.error('Error: found "packages/browser/dart.js" in the ' + |
| 66 'page. Please remove it. When using polymer\'s "boot.js", ' + |
| 67 'you can\'t use "dart.js".'); |
| 68 } |
| 69 }); |
| 60 | 70 |
| 61 // Load HTML Imports: | 71 // Load HTML Imports: |
| 62 var htmlImportsSrc = 'src="packages/html_import/html_import.min.js"'; | 72 var htmlImportsSrc = 'src="packages/html_import/html_import.min.js"'; |
| 63 document.write('<script ' + htmlImportsSrc + '></script>'); | 73 document.write('<script ' + htmlImportsSrc + '></script>'); |
| 64 var importScript = document.querySelector('script[' + htmlImportsSrc + ']'); | 74 var importScript = document.querySelector('script[' + htmlImportsSrc + ']'); |
| 65 importScript.addEventListener('load', function() { | 75 importScript.addEventListener('load', function() { |
| 66 // NOTE: this is from polymer/src/lib/dom.js | 76 // NOTE: this is from polymer/src/lib/dom.js |
| 67 window.HTMLImports.importer.preloadSelectors += | 77 window.HTMLImports.importer.preloadSelectors += |
| 68 ', polymer-element link[rel=stylesheet]'; | 78 ', polymer-element link[rel=stylesheet]'; |
| 69 }); | 79 }); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 alreadyRan = true; | 185 alreadyRan = true; |
| 176 var ref = document.body.children[0]; | 186 var ref = document.body.children[0]; |
| 177 inlinePolymerElements(document, ref); | 187 inlinePolymerElements(document, ref); |
| 178 mergeScripts(); | 188 mergeScripts(); |
| 179 if (!navigator.webkitStartDart()) { | 189 if (!navigator.webkitStartDart()) { |
| 180 document.body.innerHTML = 'This build has expired. Please download a ' + | 190 document.body.innerHTML = 'This build has expired. Please download a ' + |
| 181 'new Dartium at http://www.dartlang.org/dartium/index.html'; | 191 'new Dartium at http://www.dartlang.org/dartium/index.html'; |
| 182 } | 192 } |
| 183 }); | 193 }); |
| 184 })(); | 194 })(); |
| OLD | NEW |