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