OLD | NEW |
1 part of base; | |
2 | |
3 // 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 |
4 // 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 |
5 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
6 | 4 |
7 /** | 5 /** |
8 * Embedded DSL for generating DOM elements. | 6 * Embedded DSL for generating DOM elements. |
9 */ | 7 */ |
10 class Dom { | 8 class Dom { |
11 static void ready(void f()) { | 9 static void ready(void f()) { |
12 if (document.readyState == 'interactive' || | 10 if (document.readyState == 'interactive' || |
13 document.readyState == 'complete') { | 11 document.readyState == 'complete') { |
14 window.setTimeout(f, 0); | 12 window.setTimeout(f, 0); |
15 } else { | 13 } else { |
16 // TODO(jacobr): give this event a named property. | 14 // TODO(jacobr): give this event a named property. |
17 window.on.contentLoaded.add((Event e) { f(); }); | 15 window.on.contentLoaded.add((Event e) { f(); }); |
18 } | 16 } |
19 } | 17 } |
20 | 18 |
21 /** Adds the given <style> text to the page. */ | 19 /** Adds the given <style> text to the page. */ |
22 static void addStyle(String cssText) { | 20 static void addStyle(String cssText) { |
23 StyleElement style = new Element.tag('style'); | 21 StyleElement style = new Element.tag('style'); |
24 style.type = 'text/css'; | 22 style.type = 'text/css'; |
25 style.text = cssText; | 23 style.text = cssText; |
26 document.head.nodes.add(style); | 24 document.head.nodes.add(style); |
27 } | 25 } |
28 } | 26 } |
OLD | NEW |