File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -72,12 +72,6 @@ export function merge_ssr_styles(style_attribute, style_directive) {
72
72
const ATTR_REGEX = / [ & " ] / g;
73
73
const CONTENT_REGEX = / [ & < ] / g;
74
74
75
- const escapes = {
76
- '"' : '"' ,
77
- '&' : '&' ,
78
- '<' : '<'
79
- } ;
80
-
81
75
export function escape ( html : string , is_attr = false ) {
82
76
if ( typeof html !== 'string' ) return html ;
83
77
@@ -87,11 +81,12 @@ export function escape(html: string, is_attr = false) {
87
81
let escaped = '' ;
88
82
let last = 0 ;
89
83
90
- while ( pattern . test ( html ) ) {
91
- const i = pattern . lastIndex - 1 ;
92
- escaped += html . slice ( last , i ) + escapes [ html [ i ] ] ;
93
- last = i + 1 ;
94
- }
84
+ while ( pattern . test ( html ) ) {
85
+ const i = pattern . lastIndex - 1 ;
86
+ const ch = html [ i ] ;
87
+ escaped += html . slice ( last , i ) + ( ch === '&' ? '&' : ( ch === '"' ? '"' : '<' ) ) ;
88
+ last = i + 1 ;
89
+ }
95
90
96
91
return escaped + html . slice ( last ) ;
97
92
}
You can’t perform that action at this time.
0 commit comments