diff --git a/lib/less/browser.js b/lib/less/browser.js index c5d16805..807890a3 100644 --- a/lib/less/browser.js +++ b/lib/less/browser.js @@ -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); }); }); diff --git a/lib/less/tree.js b/lib/less/tree.js index c5572880..a1d4878c 100644 --- a/lib/less/tree.js +++ b/lib/less/tree.js @@ -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++) {