CSSLint: rewrite readNumber()

This commit is contained in:
tophf 2017-12-25 02:20:53 +03:00
parent 4b2bfd4113
commit b70beac3c9

View File

@ -5514,39 +5514,10 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
return whitespace;
},
readNumber: function(first) {
var reader = this._reader,
number = first,
hasDot = (first === "."),
hasExp,
c = reader.peek();
while (c) {
if (isDigit(c)) {
number += reader.read();
} else if (c === ".") {
if (hasDot) {
break;
} else {
hasDot = true;
number += reader.read();
}
} else if (c === 'e' || c === 'E') {
if (hasExp) {
break;
} else {
hasExp = true;
hasDot = true;
number += reader.read();
}
} else {
break;
}
c = reader.peek();
}
return number;
const tail = this._reader.readMatch(
first === "." ? /^\d+(e[+-]?\d+)?/ :
/^(\d*\.\d+|\d+\.?\d*)(e[+-]?\d+)?/);
return first + (tail || '');
},
// returns null w/o resetting reader if string is invalid.