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