less.js now works in firefox, safari and chrome

This commit is contained in:
cloudhead
2010-04-01 22:37:59 -04:00
parent 30f40222e7
commit 87e209ed8a
2 changed files with 9 additions and 3 deletions

View File

@@ -7,11 +7,17 @@ for (var i = 0; i < sheets.length; i++) {
(function (sheet) { // Because the functions here are async, we need to create a closure
xhr(sheet.href, function (data) {
new(less.Parser)({ optimization: 3 }).parse(data, function (e, root) {
var css = document.createElement('style');
var css = document.createElement('style'), styles;
css.type = 'text/css';
css.media = 'screen';
css.title = sheet.title || sheet.href.match(/\/([-\w]+)\.[a-z]+$/i)[1];
css.innerHTML = root.toCSS();
styles = root.toCSS();
if (css.styleSheet) {
css.styleSheet.cssText = styles;
} else {
css.appendChild(document.createTextNode(styles));
}
document.getElementsByTagName('head')[0].appendChild(css);
});
});

View File

@@ -1,4 +1,4 @@
var tree = exports;
if (typeof(require) !== 'undefined') { var tree = exports }
tree.find = function (obj, fun) {
for (var i = 0, r; i < obj.length; i++) {