CSSLint: rewrite readNumber()
This commit is contained in:
parent
4b2bfd4113
commit
b70beac3c9
|
@ -5514,39 +5514,10 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
|
||||||
return whitespace;
|
return whitespace;
|
||||||
},
|
},
|
||||||
readNumber: function(first) {
|
readNumber: function(first) {
|
||||||
var reader = this._reader,
|
const tail = this._reader.readMatch(
|
||||||
number = first,
|
first === "." ? /^\d+(e[+-]?\d+)?/ :
|
||||||
hasDot = (first === "."),
|
/^(\d*\.\d+|\d+\.?\d*)(e[+-]?\d+)?/);
|
||||||
hasExp,
|
return first + (tail || '');
|
||||||
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;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// returns null w/o resetting reader if string is invalid.
|
// returns null w/o resetting reader if string is invalid.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user