[2.2.6 / 2014-xx-xx](https://github.com/GoalSmashers/clean-css/compare/v2.2.5...v2.2.6)
==================
+* Adds faster quote matching in QuoteScanner.
* Improves QuoteScanner to handle comments correctly.
* Fixed issue [#308](https://github.com/GoalSmashers/clean-css/issues/308) - parsing comments in quoted urls.
* Fixed issue [#311](https://github.com/GoalSmashers/clean-css/issues/311) - leading/trailing decimal points.
this.data = data;
};
- var findCommentEnd = function(data, matched, start) {
+ var findCommentEnd = function(data, matched, cursor) {
var commentStartMark = '/*';
var commentEndMark = '*/';
- var end = start;
- while (true) {
- var from = end;
-
- end = data.indexOf(matched, from);
- var commentStart = data.indexOf(commentStartMark, from);
- var commentEnd = data.indexOf(commentEndMark, from);
+ var escapeMark = '\\';
+ var commentStarted = false;
- if (end > -1 && commentEnd > -1 && commentEnd < end && (commentStart == -1 || commentStart > commentEnd)) {
- end = commentEnd + 1;
+ while (true) {
+ if (data[cursor] === undefined)
break;
- }
-
- if (end > -1 && data[end - 1] == '\\') {
- end += 1;
- continue;
- } else {
+ if (!commentStarted && data[cursor] == commentEndMark[1] && data[cursor - 1] == commentEndMark[0])
break;
- }
+ if (data[cursor] == matched && data[cursor - 1] != escapeMark)
+ break;
+ if (data[cursor] == commentStartMark[1] && data[cursor - 1] == commentStartMark[0])
+ commentStarted = true;
+
+ cursor++;
}
- return end;
+ return cursor;
};
QuoteScanner.prototype.each = function(callback) {
var text = data.substring(nextStart, nextEnd + 1);
tempData.push(data.substring(cursor, nextStart));
- callback(text, tempData, nextStart);
+ if (text.length > 0)
+ callback(text, tempData, nextStart);
cursor = nextEnd + 1;
}