mirror of
https://github.com/less/less.js.git
synced 2026-02-04 12:05:06 -05:00
Fixes for IE7 compatibility
This commit is contained in:
committed by
Alexis Sellier
parent
61c2b5877a
commit
e501f2e47c
@@ -99,7 +99,7 @@ less.Parser = function Parser(env) {
|
||||
// or match a regexp in the current chunk (chunk[j]).
|
||||
//
|
||||
} else if (typeof(tok) === 'string') {
|
||||
match = input[i] === tok ? tok : null;
|
||||
match = input.charAt(i) === tok ? tok : null;
|
||||
length = 1;
|
||||
|
||||
// 1. We move to the next chunk, if necessary.
|
||||
@@ -138,6 +138,10 @@ less.Parser = function Parser(env) {
|
||||
if (! (c === 32 || c === 10 || c === 9)) { break }
|
||||
i++;
|
||||
}
|
||||
|
||||
if(typeof(match) === 'string')
|
||||
return match;
|
||||
|
||||
return match.length === 1 ? match[0] : match;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +152,7 @@ less.Parser = function Parser(env) {
|
||||
var match;
|
||||
|
||||
if (typeof(tok) === 'string') {
|
||||
return input[i] === tok;
|
||||
return input.charAt(i) === tok;
|
||||
} else {
|
||||
tok.lastIndex = i;
|
||||
|
||||
@@ -230,7 +234,7 @@ less.Parser = function Parser(env) {
|
||||
lines = input.split('\n');
|
||||
line = (input.slice(0, i).match(/\n/g) || "").length + 1;
|
||||
|
||||
for (var n = i, column = -1; input[n] !== '\n'; n--) { column++ }
|
||||
for (var n = i, column = -1; n >= 0 && input.charAt(n) !== '\n'; n--) { column++ }
|
||||
|
||||
error = {
|
||||
name: "ParseError",
|
||||
@@ -314,7 +318,7 @@ less.Parser = function Parser(env) {
|
||||
comment: function () {
|
||||
var comment;
|
||||
|
||||
if (input[i] !== '/') return;
|
||||
if (input.charAt(i) !== '/') return;
|
||||
|
||||
if (comment = $(/\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/g)) {
|
||||
return new(tree.Comment)(comment);
|
||||
@@ -334,7 +338,7 @@ less.Parser = function Parser(env) {
|
||||
//
|
||||
quoted: function () {
|
||||
var str;
|
||||
if (input[i] !== '"' && input[i] !== "'") return;
|
||||
if (input.charAt(i) !== '"' && input.charAt(i) !== "'") return;
|
||||
|
||||
if (str = $(/"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/g)) {
|
||||
return new(tree.Quoted)(str[0], str[1] || str[2]);
|
||||
@@ -399,7 +403,7 @@ less.Parser = function Parser(env) {
|
||||
url: function () {
|
||||
var value;
|
||||
|
||||
if (input[i] !== 'u' || !$(/url\(/g)) return;
|
||||
if (input.charAt(i) !== 'u' || !$(/url\(/g)) return;
|
||||
value = $(this.entities.quoted) || $(/[-a-zA-Z0-9_%@$\/.&=:;#+?]+/g);
|
||||
if (! $(')')) throw new(Error)("missing closing ) for url()");
|
||||
|
||||
@@ -417,7 +421,7 @@ less.Parser = function Parser(env) {
|
||||
variable: function () {
|
||||
var name;
|
||||
|
||||
if (input[i] === '@' && (name = $(/@[a-zA-Z0-9_-]+/g))) {
|
||||
if (input.charAt(i) === '@' && (name = $(/@[a-zA-Z0-9_-]+/g))) {
|
||||
return new(tree.Variable)(name);
|
||||
}
|
||||
},
|
||||
@@ -432,7 +436,7 @@ less.Parser = function Parser(env) {
|
||||
color: function () {
|
||||
var rgb;
|
||||
|
||||
if (input[i] === '#' && (rgb = $(/#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/g))) {
|
||||
if (input.charAt(i) === '#' && (rgb = $(/#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/g))) {
|
||||
return new(tree.Color)(rgb[1]);
|
||||
}
|
||||
},
|
||||
@@ -460,7 +464,7 @@ less.Parser = function Parser(env) {
|
||||
variable: function () {
|
||||
var name;
|
||||
|
||||
if (input[i] === '@' && (name = $(/(@[a-zA-Z0-9_-]+)\s*:/g))) { return name[1] }
|
||||
if (input.charAt(i) === '@' && (name = $(/(@[a-zA-Z0-9_-]+)\s*:/g))) { return name[1] }
|
||||
},
|
||||
|
||||
//
|
||||
@@ -531,7 +535,7 @@ less.Parser = function Parser(env) {
|
||||
definition: function () {
|
||||
var name, params = [], match, ruleset, param, value;
|
||||
|
||||
if (input[i] !== '.' || peek(/[^{]*(;|})/g)) return;
|
||||
if (input.charAt(i) !== '.' || peek(/[^{]*(;|})/g)) return;
|
||||
|
||||
if (match = $(/([#.][a-zA-Z0-9_-]+)\s*\(/g)) {
|
||||
name = match[1];
|
||||
@@ -633,7 +637,7 @@ less.Parser = function Parser(env) {
|
||||
if (match = $(/[+>~]/g) || $('&') || $(/::/g)) {
|
||||
return new(tree.Combinator)(match);
|
||||
} else {
|
||||
return new(tree.Combinator)(input[i - 1] === " " ? " " : null);
|
||||
return new(tree.Combinator)(input.charAt(i - 1) === " " ? " " : null);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -714,7 +718,7 @@ less.Parser = function Parser(env) {
|
||||
var memo = i;
|
||||
|
||||
if (name = $(this.property) || $(this.variable)) {
|
||||
if ((name[0] != '@') && (match = peek(/([^@+\/*(;{}-]*);/g))) {
|
||||
if ((name.charAt(0) != '@') && (match = peek(/([^@+\/*(;{}-]*);/g))) {
|
||||
i += match[0].length - 1;
|
||||
value = new(tree.Anonymous)(match[1]);
|
||||
} else if (name === "font") {
|
||||
@@ -759,7 +763,7 @@ less.Parser = function Parser(env) {
|
||||
directive: function () {
|
||||
var name, value, rules, types;
|
||||
|
||||
if (input[i] !== '@') return;
|
||||
if (input.charAt(i) !== '@') return;
|
||||
|
||||
if (value = $(this['import'])) {
|
||||
return value;
|
||||
@@ -838,7 +842,7 @@ less.Parser = function Parser(env) {
|
||||
addition: function () {
|
||||
var m, a, op, operation;
|
||||
if (m = $(this.multiplication)) {
|
||||
while ((op = $(/[-+]\s+/g) || (input[i - 1] != ' ' && $(/[-+]/g))) &&
|
||||
while ((op = $(/[-+]\s+/g) || (input.charAt(i - 1) != ' ' && $(/[-+]/g))) &&
|
||||
(a = $(this.multiplication))) {
|
||||
operation = new(tree.Operation)(op, [operation || m, a]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user