File tree 1 file changed +10
-12
lines changed
1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change 28
28
var codeUnit ;
29
29
var result = '' ;
30
30
var firstCodeUnit = string . charCodeAt ( 0 ) ;
31
+
32
+ if (
33
+ // If the character is the first character and is a `-` (U+002D), and
34
+ // there is no second character, […]
35
+ length == 1 &&
36
+ firstCodeUnit == 0x002D
37
+ ) {
38
+ return '\\' + string ;
39
+ }
40
+
31
41
while ( ++ index < length ) {
32
42
codeUnit = string . charCodeAt ( index ) ;
33
43
// Note: there’s no need to special-case astral symbols, surrogate
60
70
continue ;
61
71
}
62
72
63
- if (
64
- // If the character is the first character and is a `-` (U+002D), and
65
- // there is no second character, […]
66
- index == 0 &&
67
- length == 1 &&
68
- codeUnit == 0x002D
69
- ) {
70
- result += '\\' + string . charAt ( index ) ;
71
- continue ;
72
- }
73
-
74
73
// If the character is not handled by one of the above rules and is
75
74
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
76
75
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
91
90
// Otherwise, the escaped character.
92
91
// https://drafts.csswg.org/cssom/#escape-a-character
93
92
result += '\\' + string . charAt ( index ) ;
94
-
95
93
}
96
94
return result ;
97
95
} ;
You can’t perform that action at this time.
0 commit comments