File tree 4 files changed +43
-14
lines changed
src/compiler/compile/render_dom/wrappers/InlineComponent
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 {
347
347
}
348
348
349
349
const params = [ x `#value` ] ;
350
+ const args = [ x `#value` ] ;
350
351
if ( contextual_dependencies . length > 0 ) {
351
- const args = [ ] ;
352
352
353
353
contextual_dependencies . forEach ( name => {
354
354
params . push ( {
@@ -361,25 +361,30 @@ export default class InlineComponentWrapper extends Wrapper {
361
361
} ) ;
362
362
363
363
364
- block . chunks . init . push ( b `
365
- function ${ id } (#value) {
366
- ${ callee } .call(null, #value, ${ args } );
367
- }
368
- ` ) ;
369
-
370
364
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 }
375
381
}
376
- ` ) ;
382
+ ` ;
377
383
}
378
384
379
385
const body = b `
380
386
function ${ id } (${ params } ) {
381
- ${ lhs } = #value;
382
- ${ renderer . invalidate ( dependencies [ 0 ] ) } ;
387
+ ${ invalidate_binding }
383
388
}
384
389
` ;
385
390
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