mirror of
https://github.com/less/less.js.git
synced 2026-01-23 22:27:57 -05:00
Fix for IE6 compatibility
This commit is contained in:
committed by
Alexis Sellier
parent
f01976bb03
commit
93edde50d2
@@ -62,7 +62,7 @@ function createCSS(styles, sheet, lastModified) {
|
||||
}
|
||||
|
||||
function xhr(url, callback, errback) {
|
||||
var xhr = new(XMLHttpRequest);
|
||||
var xhr = getXMLHttpRequest();
|
||||
|
||||
if (window.location.protocol === "file:") {
|
||||
xhr.open('GET', url, false);
|
||||
@@ -75,12 +75,12 @@ function xhr(url, callback, errback) {
|
||||
} else {
|
||||
xhr.open('GET', url, true);
|
||||
xhr.onreadystatechange = function () {
|
||||
if (this.readyState == 4) {
|
||||
if (this.status >= 200 && this.status < 300) {
|
||||
callback(this.responseText,
|
||||
this.getResponseHeader("Last-Modified"));
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
callback(xhr.responseText,
|
||||
xhr.getResponseHeader("Last-Modified"));
|
||||
} else if (typeof(errback) === 'function') {
|
||||
errback(this.responseText);
|
||||
errback(xhr.responseText);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -88,6 +88,18 @@ function xhr(url, callback, errback) {
|
||||
}
|
||||
}
|
||||
|
||||
function getXMLHttpRequest() {
|
||||
if (window.XMLHttpRequest) {
|
||||
return new(XMLHttpRequest);
|
||||
} else {
|
||||
try {
|
||||
return new(ActiveXObject)("MSXML2.XMLHTTP.3.0");
|
||||
} catch(ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function log(str) {
|
||||
if (less.env == 'development' && typeof(console) !== "undefined") { console.log(str) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user