csslint: fix PropertyValuePart.serializeString

Two old csslint bugs fixed:
* in the absence of capturing groups the replacer function receives the text and index
* the actual string "c" should be used to get character codes, not String class
This commit is contained in:
tophf 2017-11-14 09:08:04 +03:00
parent 70a827b033
commit 2a95793de0

View File

@ -4258,14 +4258,14 @@ PropertyValuePart.parseString = function(str) {
* Helper method to serialize a CSS string.
*/
PropertyValuePart.serializeString = function(value) {
var replacer = function(match, c) {
var replacer = function(c) {
if (c === "\"") {
return "\\" + c;
}
var cp = String.codePointAt ? String.codePointAt(0) :
var cp = String.codePointAt ? c.codePointAt(0) :
// We only escape non-surrogate chars, so using charCodeAt
// is harmless here.
String.charCodeAt(0);
c.charCodeAt(0);
return "\\" + cp.toString(16) + " ";
};
return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";