| 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 window.setTimeout(f, 0); | 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) { f(); }); |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 /** Adds the given <style> text to the page. */ | 21 /** Adds the given <style> text to the page. */ |
| 22 static void addStyle(String cssText) { | 22 static void addStyle(String cssText) { |
| 23 StyleElement style = new Element.tag('style'); | 23 StyleElement style = new Element.tag('style'); |
| 24 style.type = 'text/css'; | 24 style.type = 'text/css'; |
| 25 style.text = cssText; | 25 style.text = cssText; |
| 26 document.head.nodes.add(style); | 26 document.head.nodes.add(style); |
| 27 } | 27 } |
| 28 } | 28 } |
| OLD | NEW |