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:
parent
70a827b033
commit
2a95793de0
|
@ -4258,14 +4258,14 @@ PropertyValuePart.parseString = function(str) {
|
||||||
* Helper method to serialize a CSS string.
|
* Helper method to serialize a CSS string.
|
||||||
*/
|
*/
|
||||||
PropertyValuePart.serializeString = function(value) {
|
PropertyValuePart.serializeString = function(value) {
|
||||||
var replacer = function(match, c) {
|
var replacer = function(c) {
|
||||||
if (c === "\"") {
|
if (c === "\"") {
|
||||||
return "\\" + 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
|
// We only escape non-surrogate chars, so using charCodeAt
|
||||||
// is harmless here.
|
// is harmless here.
|
||||||
String.charCodeAt(0);
|
c.charCodeAt(0);
|
||||||
return "\\" + cp.toString(16) + " ";
|
return "\\" + cp.toString(16) + " ";
|
||||||
};
|
};
|
||||||
return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";
|
return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user