OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 part of base; | 5 part of base; |
6 | 6 |
7 /** | 7 /** |
8 * Embedded DSL for generating DOM elements. | 8 * Embedded DSL for generating DOM elements. |
9 */ | 9 */ |
10 class Dom { | 10 class Dom { |
11 static void ready(void f()) { | 11 static void ready(void f()) { |
12 if (document.readyState == 'interactive' || | 12 if (document.readyState == 'interactive' || |
13 document.readyState == 'complete') { | 13 document.readyState == 'complete') { |
14 Timer.run(f); | 14 Timer.run(f); |
15 } else { | 15 } else { |
16 // TODO(jacobr): give this event a named property. | 16 // TODO(jacobr): give this event a named property. |
17 window.onContentLoaded.listen((Event e) { f(); }); | 17 window.onContentLoaded.listen((Event e) { |
| 18 f(); |
| 19 }); |
18 } | 20 } |
19 } | 21 } |
20 | 22 |
21 /** Adds the given <style> text to the page. */ | 23 /** Adds the given <style> text to the page. */ |
22 static void addStyle(String cssText) { | 24 static void addStyle(String cssText) { |
23 StyleElement style = new Element.tag('style'); | 25 StyleElement style = new Element.tag('style'); |
24 style.type = 'text/css'; | 26 style.type = 'text/css'; |
25 style.text = cssText; | 27 style.text = cssText; |
26 document.head.nodes.add(style); | 28 document.head.nodes.add(style); |
27 } | 29 } |
28 } | 30 } |
OLD | NEW |