File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 60
60
if ( node . parent ) {
61
61
var ss = node . previous ? node . previous . end : node . parent . start ;
62
62
t = text . substring ( ss , node . start - 1 ) ;
63
+ t = this . _expandUnicodeEscapes ( t ) ;
63
64
// TODO(sorvell): ad hoc; make selector include only after last ;
64
65
// helps with mixin syntax
65
66
t = t . substring ( t . lastIndexOf ( ';' ) + 1 ) ;
89
90
return node ;
90
91
} ,
91
92
93
+ // conversion of sort unicode escapes with spaces like `\33 ` (and longer) into
94
+ // expanded form that doesn't require trailing space `\000033`
95
+ _expandUnicodeEscapes : function ( s ) {
96
+ return s . replace ( / \\ ( [ 0 - 9 a - f ] { 1 , 6 } ) \s / gi, function ( ) {
97
+ var code = arguments [ 1 ] , repeat = 6 - code . length ;
98
+ while ( repeat -- ) {
99
+ code = '0' + code ;
100
+ }
101
+ return '\\' + code ;
102
+ } ) ;
103
+ } ,
104
+
92
105
// stringify parsed css.
93
106
stringify : function ( node , preserveProperties , text ) {
94
107
text = text || '' ;
Original file line number Diff line number Diff line change 68
68
someProperty: thatMustNotShowUp
69
69
}*/
70
70
</ style >
71
+
72
+ < style id ="short-escape-sequence ">
73
+ .\33 d-model {
74
+ border-top : 3px solid red;
75
+ }
76
+ .\a33 d-model {
77
+ border-top : 3px solid red;
78
+ }
79
+ .\b333 d-model {
80
+ border-top : 3px solid red;
81
+ }
82
+ .\c3333 d-model {
83
+ border-top : 3px solid red;
84
+ }
85
+ .\d33333 d-model {
86
+ border-top : 3px solid red;
87
+ }
88
+ .\e33333d-model {
89
+ border-top : 3px solid red;
90
+ }
91
+ </ style >
71
92
< script >
72
93
73
94
function sanitizeCss ( text ) {
127
148
assert . equal ( result , '.stuff { background: red; }' , 'unexpected stringified output' ) ;
128
149
} ) ;
129
150
151
+ test ( 'short escape sequences' , function ( ) {
152
+ var s3 = document . querySelector ( '#short-escape-sequence' ) ;
153
+ var t = css . parse ( s3 . textContent ) ;
154
+ assert . equal ( t . rules [ 0 ] . selector , '.\\000033d-model' ) ;
155
+ assert . equal ( t . rules [ 1 ] . selector , '.\\000a33d-model' ) ;
156
+ assert . equal ( t . rules [ 2 ] . selector , '.\\00b333d-model' ) ;
157
+ assert . equal ( t . rules [ 3 ] . selector , '.\\0c3333d-model' ) ;
158
+ assert . equal ( t . rules [ 4 ] . selector , '.\\d33333d-model' ) ;
159
+ assert . equal ( t . rules [ 5 ] . selector , '.\\e33333d-model' ) ;
160
+ } ) ;
161
+
130
162
} ) ;
131
163
</ script >
132
164
You can’t perform that action at this time.
0 commit comments