This commit is contained in:
Nicolas Stepien 2012-09-14 19:53:59 +02:00
parent 1d267e0541
commit 9329c7ce6e
2 changed files with 20 additions and 4 deletions

View File

@ -402,11 +402,19 @@
} }
}, },
addStyle: function(css) { addStyle: function(css) {
var style; var f, style;
style = $.el('style', { style = $.el('style', {
textContent: css textContent: css
}); });
$.add(d.head || d.documentElement, style); f = function() {
var root;
if (root = d.head || d.documentElement) {
return $.add(root, style);
} else {
return setTimeout(f, 20);
}
};
f();
return style; return style;
}, },
x: function(path, root) { x: function(path, root) {

View File

@ -315,8 +315,16 @@ $.extend $,
addStyle: (css) -> addStyle: (css) ->
style = $.el 'style', style = $.el 'style',
textContent: css textContent: css
# XXX Only Chrome has no d.head on document-start. # That's terrible.
$.add d.head or d.documentElement, style # XXX tmp fix for scriptish:
# https://github.com/scriptish/scriptish/issues/16
f = ->
# XXX Only Chrome has no d.head on document-start.
if root = d.head or d.documentElement
$.add root, style
else
setTimeout f, 20
f()
style style
x: (path, root=d.body) -> x: (path, root=d.body) ->
# XPathResult.ANY_UNORDERED_NODE_TYPE is 8 # XPathResult.ANY_UNORDERED_NODE_TYPE is 8