Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dev_compiler.src.codegen.html_codegen; | 5 library dev_compiler.src.codegen.html_codegen; |
| 6 | 6 |
| 7 import 'package:html/dom.dart'; | 7 import 'package:html/dom.dart'; |
| 8 import 'package:html/parser.dart' show parseFragment; | 8 import 'package:html/parser.dart' show parseFragment; |
| 9 import 'package:logging/logging.dart' show Logger; | 9 import 'package:logging/logging.dart' show Logger; |
| 10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 /// runtime and the compiled code, and to execute the main method of the | 21 /// runtime and the compiled code, and to execute the main method of the |
| 22 /// application. When compiling to Dart, we ensure that the document contains a | 22 /// application. When compiling to Dart, we ensure that the document contains a |
| 23 /// single Dart script tag, but otherwise emit the original document | 23 /// single Dart script tag, but otherwise emit the original document |
| 24 /// unmodified. | 24 /// unmodified. |
| 25 String generateEntryHtml(HtmlSourceNode root, AbstractCompiler compiler) { | 25 String generateEntryHtml(HtmlSourceNode root, AbstractCompiler compiler) { |
| 26 var options = compiler.options; | 26 var options = compiler.options; |
| 27 var document = root.document.clone(true); | 27 var document = root.document.clone(true); |
| 28 var scripts = document.querySelectorAll('script[type="application/dart"]'); | 28 var scripts = document.querySelectorAll('script[type="application/dart"]'); |
| 29 if (scripts.isEmpty) { | 29 if (scripts.isEmpty) { |
| 30 _log.warning('No <script type="application/dart"> found in ${root.uri}'); | 30 _log.warning('No <script type="application/dart"> found in ${root.uri}'); |
| 31 return '${document.outerHtml}\n'; | 31 return root.contents; |
|
Jennifer Messerly
2016/01/13 18:05:02
This could use a comment.
| |
| 32 } | 32 } |
| 33 scripts.skip(1).forEach((s) { | 33 scripts.skip(1).forEach((s) { |
| 34 // TODO(sigmund): allow more than one Dart script tags? | 34 // TODO(sigmund): allow more than one Dart script tags? |
| 35 _log.warning(s.sourceSpan.message( | 35 _log.warning(s.sourceSpan.message( |
| 36 'unexpected script. Only one Dart script tag allowed ' | 36 'unexpected script. Only one Dart script tag allowed ' |
| 37 '(see https://github.com/dart-lang/dart-dev-compiler/issues/53).', | 37 '(see https://github.com/dart-lang/dart-dev-compiler/issues/53).', |
| 38 color: options.useColors ? colorOf('warning') : false)); | 38 color: options.useColors ? colorOf('warning') : false)); |
| 39 s.remove(); | 39 s.remove(); |
| 40 }); | 40 }); |
| 41 | 41 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 | 119 |
| 120 /// Convert the outputPath to include the hash in it. This function is the | 120 /// Convert the outputPath to include the hash in it. This function is the |
| 121 /// reverse of what the server does to determine whether a request needs to have | 121 /// reverse of what the server does to determine whether a request needs to have |
| 122 /// cache headers added to it. | 122 /// cache headers added to it. |
| 123 _addHash(String outPath, String hash) { | 123 _addHash(String outPath, String hash) { |
| 124 // (the ____ prefix makes it look better in the web inspector) | 124 // (the ____ prefix makes it look better in the web inspector) |
| 125 return '$outPath?____cached=$hash'; | 125 return '$outPath?____cached=$hash'; |
| 126 } | 126 } |
| 127 | 127 |
| 128 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); | 128 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); |
| OLD | NEW |