mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
htmlconverter: suggestions from dstockwell
Review URL: https://chromereviews.googleplex.com/3532012 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@76 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
57051017bd
commit
ebd67ed258
|
@ -24,6 +24,7 @@ sys.path.append(TOOLS_PATH)
|
|||
import utils
|
||||
|
||||
DART_MIME_TYPE = "application/dart"
|
||||
LIBRARY_PATTERN = "^#library\(.*\);"
|
||||
IMPORT_SOURCE_PATTERN = "(#import|#source)(\(['\"])([^'\"]*)(['\"]\);)"
|
||||
|
||||
DARTC_INLINE_CODE_ADDITIONAL_IMPORTS = """
|
||||
|
@ -37,13 +38,7 @@ ENTRY_POINT = """
|
|||
#import('dart:dom');
|
||||
#import('%s', prefix: 'original');
|
||||
main() {
|
||||
// Ensure the code starts on DOM content loaded.
|
||||
if (document.readyState == "interactive" ||
|
||||
document.readyState == "complete") {
|
||||
original.main();
|
||||
} else {
|
||||
window.addEventListener('DOMContentLoaded', (e) => original.main(), false);
|
||||
}
|
||||
window.addEventListener('DOMContentLoaded', (e) => original.main(), false);
|
||||
}
|
||||
"""
|
||||
|
||||
|
@ -99,7 +94,7 @@ class DartCompiler(object):
|
|||
|
||||
# We will import the source file to emulate in JS that code is run after
|
||||
# DOMContentLoaded. We need a #library to ensure #import won't fail:
|
||||
if not '#library' in contents:
|
||||
if not re.search(LIBRARY_PATTERN, contents, re.MULTILINE):
|
||||
def repl(matchobj):
|
||||
path = matchobj.group(3)
|
||||
if path.startswith('dart:'):
|
||||
|
|
Loading…
Reference in a new issue