| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import 'package:html/dom.dart'; | |
| 6 import 'package:html/parser.dart' show parseFragment; | |
| 7 import 'package:logging/logging.dart' show Logger; | |
| 8 | |
| 9 // TODO(jmesserly): the string interpolation in these could lead to injection | |
| 10 // bugs. Not really a security issue since input is trusted, but the resulting | |
| 11 // parse tree may not match expectations if interpolated strings contain quotes. | |
| 12 | |
| 13 /// A script tag that loads the .js code for a compiled library. | |
| 14 Node libraryInclude(String jsUrl) => | |
| 15 parseFragment('<script src="$jsUrl"></script>\n'); | |
| 16 | |
| 17 /// A script tag that invokes the main function on the entry point library. | |
| 18 Node invokeMain(String mainLibraryName) { | |
| 19 var code = mainLibraryName == null | |
| 20 ? 'console.error("dev_compiler error: main was not generated");' | |
| 21 // TODO(vsm): Can we simplify this? | |
| 22 // See: https://github.com/dart-lang/dev_compiler/issues/164 | |
| 23 : "dart_library.start('$mainLibraryName');"; | |
| 24 return parseFragment('<script>$code</script>\n'); | |
| 25 } | |
| 26 | |
| 27 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); | |
| OLD | NEW |