@@ -2,7 +2,9 @@ import { set_current_component, current_component } from './lifecycle.js';
2
2
import { run_all , blank_object } from './utils.js' ;
3
3
import { boolean_attributes } from '../../shared/boolean_attributes.js' ;
4
4
import { ensure_array_like } from './each.js' ;
5
+ import { escape } from '../../shared/utils/escape.js' ;
5
6
export { is_void } from '../../shared/utils/names.js' ;
7
+ export { escape } ;
6
8
7
9
export const invalid_attribute_name_character =
8
10
/ [ \s ' " > / = \u{FDD0} - \u{FDEF} \u{FFFE} \u{FFFF} \u{1FFFE} \u{1FFFF} \u{2FFFE} \u{2FFFF} \u{3FFFE} \u{3FFFF} \u{4FFFE} \u{4FFFF} \u{5FFFE} \u{5FFFF} \u{6FFFE} \u{6FFFF} \u{7FFFE} \u{7FFFF} \u{8FFFE} \u{8FFFF} \u{9FFFE} \u{9FFFF} \u{AFFFE} \u{AFFFF} \u{BFFFE} \u{BFFFF} \u{CFFFE} \u{CFFFF} \u{DFFFE} \u{DFFFF} \u{EFFFE} \u{EFFFF} \u{FFFFE} \u{FFFFF} \u{10FFFE} \u{10FFFF} ] / u;
@@ -67,30 +69,6 @@ export function merge_ssr_styles(style_attribute, style_directive) {
67
69
return style_object ;
68
70
}
69
71
70
- const ATTR_REGEX = / [ & " ] / g;
71
- const CONTENT_REGEX = / [ & < ] / g;
72
-
73
- /**
74
- * Note: this method is performance sensitive and has been optimized
75
- * https://github.com/sveltejs/svelte/pull/5701
76
- * @param {unknown } value
77
- * @returns {string }
78
- */
79
- export function escape ( value , is_attr = false ) {
80
- const str = String ( value ) ;
81
- const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX ;
82
- pattern . lastIndex = 0 ;
83
- let escaped = '' ;
84
- let last = 0 ;
85
- while ( pattern . test ( str ) ) {
86
- const i = pattern . lastIndex - 1 ;
87
- const ch = str [ i ] ;
88
- escaped += str . substring ( last , i ) + ( ch === '&' ? '&' : ch === '"' ? '"' : '<' ) ;
89
- last = i + 1 ;
90
- }
91
- return escaped + str . substring ( last ) ;
92
- }
93
-
94
72
export function escape_attribute_value ( value ) {
95
73
// keep booleans, null, and undefined for the sake of `spread`
96
74
const should_escape = typeof value === 'string' || ( value && typeof value === 'object' ) ;
0 commit comments