Skip to content

Commit df2089c

Browse files
committed
Add missing escapeIdentCode(). Fixes #46
1 parent 998aced commit df2089c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

parse-css.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function nonprintable(code) { return between(code, 0,8) || code == 0xb || betwee
4242
function newline(code) { return code == 0xa; }
4343
function whitespace(code) { return newline(code) || code == 9 || code == 0x20; }
4444
function badescape(code) { return newline(code) || isNaN(code); }
45+
function surrogate(code) { return between(code, 0xd800, 0xdfff); }
4546

4647
var maximumallowedcodepoint = 0x10ffff;
4748

@@ -805,6 +806,13 @@ function escapeIdent(string) {
805806
}).join("");
806807
}
807808

809+
function escapeIdentCode(code) {
810+
if(digit(code) || letter(code)) {
811+
return `\\${code.toString(16)} `;
812+
}
813+
return "\\"+String.fromCodePoint(code);
814+
}
815+
808816
function escapeHash(string) {
809817
// Escapes the value (after the #) of a hash.
810818
return Array.from(String(string), e=>{

0 commit comments

Comments
 (0)