@@ -92,21 +92,6 @@ export function build_component(node, component_name, context, anchor = context.
9292 }
9393 }
9494
95- let safe_props_ids = new Map ( ) ;
96- let safe_props_name = context . state . scope . generate ( '$$safe_props' ) ;
97-
98- /**
99- * @param {string } name
100- * @param {Expression } expression
101- */
102- function safe_propify ( name , expression ) {
103- if ( context . state . needs_safe_props ) {
104- safe_props_ids . set ( name , expression ) ;
105- return b . member ( b . id ( safe_props_name ) , b . id ( name ) ) ;
106- }
107- return expression ;
108- }
109-
11095 for ( const attribute of node . attributes ) {
11196 if ( attribute . type === 'LetDirective' ) {
11297 if ( ! slot_scope_applies_to_itself ) {
@@ -133,14 +118,13 @@ export function build_component(node, component_name, context, anchor = context.
133118 if ( attribute . metadata . expression . has_state ) {
134119 let value = expression ;
135120
136- const name = context . state . scope . generate ( 'spread_element' ) ;
137121 if ( attribute . metadata . expression . has_call ) {
138- const id = b . id ( name ) ;
122+ const id = b . id ( context . state . scope . generate ( 'spread_element' ) ) ;
139123 context . state . init . push ( b . var ( id , b . call ( '$.derived' , b . thunk ( value ) ) ) ) ;
140124 value = b . call ( '$.get' , id ) ;
141125 }
142126
143- props_and_spreads . push ( b . thunk ( safe_propify ( name , value ) ) ) ;
127+ props_and_spreads . push ( b . thunk ( value ) ) ;
144128 } else {
145129 props_and_spreads . push ( expression ) ;
146130 }
@@ -188,7 +172,7 @@ export function build_component(node, component_name, context, anchor = context.
188172 ) ;
189173
190174 if ( has_state ) {
191- push_prop ( b . get ( attribute . name , [ b . return ( safe_propify ( attribute . name , value ) ) ] ) ) ;
175+ push_prop ( b . get ( attribute . name , [ b . return ( value ) ] ) ) ;
192176 } else {
193177 push_prop ( b . init ( attribute . name , value ) ) ;
194178 }
@@ -221,9 +205,7 @@ export function build_component(node, component_name, context, anchor = context.
221205 context . state . init . push ( b . var ( get_id , get ) ) ;
222206 context . state . init . push ( b . var ( set_id , set ) ) ;
223207
224- push_prop (
225- b . get ( attribute . name , [ b . return ( safe_propify ( attribute . name , b . call ( get_id ) ) ) ] )
226- ) ;
208+ push_prop ( b . get ( attribute . name , [ b . return ( b . call ( get_id ) ) ] ) ) ;
227209 push_prop ( b . set ( attribute . name , [ b . stmt ( b . call ( set_id , b . id ( '$$value' ) ) ) ] ) ) ;
228210 }
229211 } else {
@@ -246,17 +228,11 @@ export function build_component(node, component_name, context, anchor = context.
246228 // Delay prop pushes so bindings come at the end, to avoid spreads overwriting them
247229 if ( is_store_sub ) {
248230 push_prop (
249- b . get ( attribute . name , [
250- b . stmt ( b . call ( '$.mark_store_binding' ) ) ,
251- b . return ( safe_propify ( attribute . name , expression ) )
252- ] ) ,
231+ b . get ( attribute . name , [ b . stmt ( b . call ( '$.mark_store_binding' ) ) , b . return ( expression ) ] ) ,
253232 true
254233 ) ;
255234 } else {
256- push_prop (
257- b . get ( attribute . name , [ b . return ( safe_propify ( attribute . name , expression ) ) ] ) ,
258- true
259- ) ;
235+ push_prop ( b . get ( attribute . name , [ b . return ( expression ) ] ) , true ) ;
260236 }
261237
262238 const assignment = b . assignment (
@@ -427,32 +403,6 @@ export function build_component(node, component_name, context, anchor = context.
427403
428404 const statements = [ ...snippet_declarations ] ;
429405
430- if ( safe_props_ids . size > 0 ) {
431- // if it is a dynamic component we need to include the safe props call inside the component
432- // function otherwise in the init (which in case of the if will be in the consequent/alternate function)
433- if ( component_name === '$$component' ) {
434- statements . push (
435- b . const (
436- safe_props_name ,
437- b . call (
438- '$.safe_props' ,
439- b . object ( [ ...safe_props_ids ] . map ( ( [ name , id ] ) => b . get ( name , [ b . return ( id ) ] ) ) )
440- )
441- )
442- ) ;
443- } else {
444- context . state . init . push (
445- b . const (
446- safe_props_name ,
447- b . call (
448- '$.safe_props' ,
449- b . object ( [ ...safe_props_ids ] . map ( ( [ name , id ] ) => b . get ( name , [ b . return ( id ) ] ) ) )
450- )
451- )
452- ) ;
453- }
454- }
455-
456406 if ( node . type === 'SvelteComponent' ) {
457407 const prev = fn ;
458408
0 commit comments