From b70beac3c9f5b405378f763e84a6cec2af341db5 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 25 Dec 2017 02:20:53 +0300 Subject: [PATCH] CSSLint: rewrite readNumber() --- vendor-overwrites/csslint/csslint-worker.js | 37 +++------------------ 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/vendor-overwrites/csslint/csslint-worker.js b/vendor-overwrites/csslint/csslint-worker.js index c8416614..141de843 100644 --- a/vendor-overwrites/csslint/csslint-worker.js +++ b/vendor-overwrites/csslint/csslint-worker.js @@ -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.