| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** Collects several code emitters for the template tool. */ | 5 /** Collects several code emitters for the template tool. */ |
| 6 library emitters; | 6 library emitters; |
| 7 | 7 |
| 8 import 'package:html5lib/dom.dart'; | 8 import 'package:html5lib/dom.dart'; |
| 9 import 'package:html5lib/dom_parsing.dart' show TreeVisitor; | 9 import 'package:html5lib/dom_parsing.dart' show TreeVisitor; |
| 10 import 'package:html5lib/parser.dart' show parseFragment; | 10 import 'package:html5lib/parser.dart' show parseFragment; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 styles[0].nodes.clear(); | 172 styles[0].nodes.clear(); |
| 173 styles[0].nodes.add(new Text(allCss.toString())); | 173 styles[0].nodes.add(new Text(allCss.toString())); |
| 174 for (var i = styles.length - 1; i > 0 ; i--) { | 174 for (var i = styles.length - 1; i > 0 ; i--) { |
| 175 styles[i].remove(); | 175 styles[i].remove(); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 // TODO(jmesserly): put this in the global CSS file? | 179 // TODO(jmesserly): put this in the global CSS file? |
| 180 // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#
css-additions | 180 // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#
css-additions |
| 181 document.head.nodes.insert(0, parseFragment( | 181 document.head.nodes.insert(0, parseFragment( |
| 182 '<style>template { display: none; }</style>')); | 182 '<style shadowcssshim="">template { display: none; }</style>')); |
| 183 | 183 |
| 184 // Move all <element> declarations to the main HTML file | 184 // Move all <element> declarations to the main HTML file |
| 185 // TODO(sigmund): remove this once we have HTMLImports implemented. | 185 // TODO(sigmund): remove this once we have HTMLImports implemented. |
| 186 for (var c in global.components.values) { | 186 for (var c in global.components.values) { |
| 187 document.body.nodes.insert(0, new Text('\n')); | 187 document.body.nodes.insert(0, new Text('\n')); |
| 188 var fragment = c.element; | 188 var fragment = c.element; |
| 189 for (var tag in fragment.queryAll('script')) { | 189 for (var tag in fragment.queryAll('script')) { |
| 190 // TODO(sigmund): leave script tags around when we start using "boot.js" | 190 // TODO(sigmund): leave script tags around when we start using "boot.js" |
| 191 if (tag.attributes['type'] == 'application/dart') { | 191 if (tag.attributes['type'] == 'application/dart') { |
| 192 tag.remove(); | 192 tag.remove(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // For simplicity we emit the warning always, like validator.nu does. | 237 // For simplicity we emit the warning always, like validator.nu does. |
| 238 if (doctype.tagName != 'html' || commentIndex != 1) { | 238 if (doctype.tagName != 'html' || commentIndex != 1) { |
| 239 messages.warning('file should start with <!DOCTYPE html> ' | 239 messages.warning('file should start with <!DOCTYPE html> ' |
| 240 'to avoid the possibility of it being parsed in quirks mode in IE. ' | 240 'to avoid the possibility of it being parsed in quirks mode in IE. ' |
| 241 'See http://www.w3.org/TR/html5-diff/#doctype', doctype.sourceSpan); | 241 'See http://www.w3.org/TR/html5-diff/#doctype', doctype.sourceSpan); |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 document.nodes.insert(commentIndex, parseFragment( | 244 document.nodes.insert(commentIndex, parseFragment( |
| 245 '\n<!-- This file was auto-generated from $filePath. -->\n')); | 245 '\n<!-- This file was auto-generated from $filePath. -->\n')); |
| 246 } | 246 } |
| OLD | NEW |