Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Experimental bootstrap to initialize polymer applications. This library is | 5 /// Experimental bootstrap to initialize polymer applications. This library is |
| 6 /// not used by default, and may be replaced by Dart code in the near future. | 6 /// not used by default, and may be replaced by Dart code in the near future. |
| 7 /// | 7 /// |
| 8 /// This script contains logic to bootstrap polymer apps during development. It | 8 /// This script contains logic to bootstrap polymer apps during development. It |
| 9 /// internally discovers Dart script tags through HTML imports, and constructs | 9 /// internally discovers Dart script tags through HTML imports, and constructs |
| 10 /// a new entrypoint for the application that is then launched in an isolate. | 10 /// a new entrypoint for the application that is then launched in an isolate. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 /// script tags in the main page, so you may need to move some code into an HTML | 26 /// script tags in the main page, so you may need to move some code into an HTML |
| 27 /// import. For example, If you need to run some initialization code before any | 27 /// import. For example, If you need to run some initialization code before any |
| 28 /// other code is executed, include an HTML import to an html file with a | 28 /// other code is executed, include an HTML import to an html file with a |
| 29 /// "application/dart" script tag that contains an initializer | 29 /// "application/dart" script tag that contains an initializer |
| 30 /// method with the body of your old main, and make sure this tag is placed | 30 /// method with the body of your old main, and make sure this tag is placed |
| 31 /// above other html-imports that load the rest of the application. | 31 /// above other html-imports that load the rest of the application. |
| 32 /// Initialization methods are executed in the order in which they are | 32 /// Initialization methods are executed in the order in which they are |
| 33 /// discovered in the HTML document. | 33 /// discovered in the HTML document. |
| 34 (function() { | 34 (function() { |
| 35 // Only run in Dartium. | 35 // Only run in Dartium. |
| 36 if (navigator.userAgent.indexOf('(Dart)') === -1) return; | 36 if (!navigator.dartEnabled && |
|
kasperl
2014/08/13 07:29:33
Will we be able to simplify this and get rid of th
vsm
2014/08/13 08:24:06
Yes - this is just precautionary for the transitio
Siggi Cherem (dart-lang)
2014/08/13 16:15:27
Done.
| |
| 37 (navigator.userAgent.indexOf('(Dart)') === -1)) { | |
| 38 return; | |
| 39 } | |
| 37 | 40 |
| 38 // Extract a Dart import URL from a script tag, which is the 'src' attribute | 41 // Extract a Dart import URL from a script tag, which is the 'src' attribute |
| 39 // of the script tag, or a data-url with the script contents for inlined code. | 42 // of the script tag, or a data-url with the script contents for inlined code. |
| 40 function getScriptUrl(script) { | 43 function getScriptUrl(script) { |
| 41 var url = script.src; | 44 var url = script.src; |
| 42 if (url) { | 45 if (url) { |
| 43 // Normalize package: urls | 46 // Normalize package: urls |
| 44 var index = url.indexOf('packages/'); | 47 var index = url.indexOf('packages/'); |
| 45 if (index == 0 || (index > 0 && url[index - 1] == '/')) { | 48 if (index == 0 || (index > 0 && url[index - 1] == '/')) { |
| 46 url = "package:" + url.slice(index + 9); | 49 url = "package:" + url.slice(index + 9); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 + 'doesn\'t have a main, but a top-level method marked with ' | 122 + 'doesn\'t have a main, but a top-level method marked with ' |
| 120 + '@initMethod instead'); | 123 + '@initMethod instead'); |
| 121 for (var i = 0; i < results.badTags.length; i++) { | 124 for (var i = 0; i < results.badTags.length; i++) { |
| 122 console.warn(results.badTags[i]); | 125 console.warn(results.badTags[i]); |
| 123 } | 126 } |
| 124 } | 127 } |
| 125 newScript.textContent = createMain(results.scripts); | 128 newScript.textContent = createMain(results.scripts); |
| 126 document.body.appendChild(newScript); | 129 document.body.appendChild(newScript); |
| 127 }); | 130 }); |
| 128 })(); | 131 })(); |
| OLD | NEW |