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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } else { | 104 } else { |
105 state.badTags.push(node); | 105 state.badTags.push(node); |
106 } | 106 } |
107 } | 107 } |
108 } | 108 } |
109 return state; | 109 return state; |
110 } | 110 } |
111 | 111 |
112 // TODO(jmesserly): we're using this function because DOMContentLoaded can | 112 // TODO(jmesserly): we're using this function because DOMContentLoaded can |
113 // be fired too soon: https://www.w3.org/Bugs/Public/show_bug.cgi?id=23526 | 113 // be fired too soon: https://www.w3.org/Bugs/Public/show_bug.cgi?id=23526 |
114 HTMLImports.whenImportsReady(function() { | 114 HTMLImports.whenReady(function() { |
115 // Append a new script tag that initializes everything. | 115 // Append a new script tag that initializes everything. |
116 var newScript = document.createElement('script'); | 116 var newScript = document.createElement('script'); |
117 newScript.type = "application/dart"; | 117 newScript.type = "application/dart"; |
118 | 118 |
119 var results = discoverScripts(document); | 119 var results = discoverScripts(document); |
120 if (results.badTags.length > 0) { | 120 if (results.badTags.length > 0) { |
121 console.warn('The experimental polymer boostrap does not support ' | 121 console.warn('The experimental polymer boostrap does not support ' |
122 + 'having script tags in the main document. You can move the script ' | 122 + 'having script tags in the main document. You can move the script ' |
123 + 'tag to an HTML import instead. Also make sure your script tag ' | 123 + 'tag to an HTML import instead. Also make sure your script tag ' |
124 + 'doesn\'t have a main, but a top-level method marked with ' | 124 + 'doesn\'t have a main, but a top-level method marked with ' |
125 + '@initMethod instead'); | 125 + '@initMethod instead'); |
126 for (var i = 0; i < results.badTags.length; i++) { | 126 for (var i = 0; i < results.badTags.length; i++) { |
127 console.warn(results.badTags[i]); | 127 console.warn(results.badTags[i]); |
128 } | 128 } |
129 } | 129 } |
130 newScript.textContent = createMain(results.scripts); | 130 newScript.textContent = createMain(results.scripts); |
131 document.body.appendChild(newScript); | 131 document.body.appendChild(newScript); |
132 }); | 132 }); |
133 })(); | 133 })(); |
OLD | NEW |