File tree Expand file tree Collapse file tree 2 files changed +4
-20
lines changed
packages/svelte/src/compiler/phases/3-transform/client Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Original file line number Diff line number Diff line change 11/**
22 * @import { TemplateOperations } from "../types.js"
33 */
4+ import { escape_html } from '../../../../../escaping.js' ;
45import { is_void } from '../../../../../utils.js' ;
56
67/**
@@ -67,7 +68,7 @@ export function template_to_string(items) {
6768 const el = /** @type {Element } */ ( last_current_element ) ;
6869 const [ prop , value ] = /** @type {string[] } */ ( instruction . args ) ;
6970 el . props ??= { } ;
70- el . props [ prop ] = value ;
71+ el . props [ prop ] = escape_html ( value , true ) ;
7172 break ;
7273 }
7374 }
Original file line number Diff line number Diff line change @@ -122,14 +122,7 @@ export function RegularElement(node, context) {
122122 if ( value . type === 'Literal' && typeof value . value === 'string' ) {
123123 context . state . template . push ( {
124124 kind : 'set_prop' ,
125- args : [
126- 'is' ,
127- // if we are using the functional template mode we don't want to escape since we will
128- // create a text node from it which is already escaped
129- context . state . is_functional_template_mode
130- ? value . value
131- : escape_html ( value . value , true )
132- ]
125+ args : [ 'is' , value . value ]
133126 } ) ;
134127 continue ;
135128 }
@@ -313,17 +306,7 @@ export function RegularElement(node, context) {
313306 context . state . template . push ( {
314307 kind : 'set_prop' ,
315308 args : [ attribute . name ] . concat (
316- is_boolean_attribute ( name ) && value === true
317- ? [ ]
318- : [
319- value === true
320- ? ''
321- : // if we are using the functional template mode we don't want to escape since we will
322- // create a text node from it which is already escaped
323- context . state . is_functional_template_mode
324- ? value
325- : escape_html ( value , true )
326- ]
309+ is_boolean_attribute ( name ) && value === true ? [ ] : [ value === true ? '' : value ]
327310 )
328311 } ) ;
329312 }
You can’t perform that action at this time.
0 commit comments