File tree Expand file tree Collapse file tree 4 files changed +43
-14
lines changed
src/compiler/compile/render_dom/wrappers/InlineComponent Expand file tree Collapse file tree 4 files changed +43
-14
lines changed Original file line number Diff line number Diff line change @@ -347,8 +347,8 @@ export default class InlineComponentWrapper extends Wrapper {
347347 }
348348
349349 const params = [ x `#value` ] ;
350+ const args = [ x `#value` ] ;
350351 if ( contextual_dependencies . length > 0 ) {
351- const args = [ ] ;
352352
353353 contextual_dependencies . forEach ( name => {
354354 params . push ( {
@@ -361,25 +361,30 @@ export default class InlineComponentWrapper extends Wrapper {
361361 } ) ;
362362
363363
364- block . chunks . init . push ( b `
365- function ${ id } (#value) {
366- ${ callee } .call(null, #value, ${ args } );
367- }
368- ` ) ;
369-
370364 block . maintain_context = true ; // TODO put this somewhere more logical
371- } else {
372- block . chunks . init . push ( b `
373- function ${ id } (#value) {
374- ${ callee } .call(null, #value);
365+ }
366+
367+ block . chunks . init . push ( b `
368+ function ${ id } (#value) {
369+ ${ callee } (${ args } );
370+ }
371+ ` ) ;
372+
373+ let invalidate_binding = b `
374+ ${ lhs } = #value;
375+ ${ renderer . invalidate ( dependencies [ 0 ] ) } ;
376+ ` ;
377+ if ( binding . expression . node . type === 'MemberExpression' ) {
378+ invalidate_binding = b `
379+ if ($$self.$$.not_equal(${ lhs } , #value)) {
380+ ${ invalidate_binding }
375381 }
376- ` ) ;
382+ ` ;
377383 }
378384
379385 const body = b `
380386 function ${ id } (${ params } ) {
381- ${ lhs } = #value;
382- ${ renderer . invalidate ( dependencies [ 0 ] ) } ;
387+ ${ invalidate_binding }
383388 }
384389 ` ;
385390
Original file line number Diff line number Diff line change 1+ <script >
2+ export let value;
3+ export let value2;
4+ </script >
5+
6+ {value }{value2 }
Original file line number Diff line number Diff line change 1+ export default {
2+ async test ( { assert, component } ) {
3+ assert . equal ( component . object_updates , component . primitive_updates ) ;
4+ }
5+ } ;
Original file line number Diff line number Diff line change 1+ <script >
2+ import Component from ' ./Component.svelte' ;
3+
4+ export let primitive_updates = 0 ;
5+ export let object_updates = 0 ;
6+
7+ const obj = { foo: ' ' };
8+ let foo = ' bar' ;
9+ $: if (obj) object_updates++ ;
10+ $: if (foo) primitive_updates++ ;
11+ </script >
12+
13+ <Component bind:value ={obj .foo } bind:value 2={foo } />
You can’t perform that action at this time.
0 commit comments