From 8ca9541391c972ad65974cdf2a05cd81c460a939 Mon Sep 17 00:00:00 2001 From: pushkine Date: Sat, 16 Jan 2021 15:00:58 +0100 Subject: [PATCH] init --- .../render_dom/wrappers/InlineComponent/index.ts | 6 ++++-- .../Component.svelte | 5 +++++ .../_config.js | 5 +++++ .../main.svelte | 10 ++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 test/runtime/samples/component-binding-reactive-property-no-extra-call/Component.svelte create mode 100644 test/runtime/samples/component-binding-reactive-property-no-extra-call/_config.js create mode 100644 test/runtime/samples/component-binding-reactive-property-no-extra-call/main.svelte diff --git a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts index be3d6d146d..515cdc0841 100644 --- a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts +++ b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts @@ -378,8 +378,10 @@ export default class InlineComponentWrapper extends Wrapper { const body = b` function ${id}(${params}) { - ${lhs} = #value; - ${renderer.invalidate(dependencies[0])}; + if ($$self.$$.not_equal(${lhs}, #value)) { + ${lhs} = #value; + ${renderer.invalidate(dependencies[0])}; + } } `; diff --git a/test/runtime/samples/component-binding-reactive-property-no-extra-call/Component.svelte b/test/runtime/samples/component-binding-reactive-property-no-extra-call/Component.svelte new file mode 100644 index 0000000000..35bea4786d --- /dev/null +++ b/test/runtime/samples/component-binding-reactive-property-no-extra-call/Component.svelte @@ -0,0 +1,5 @@ + + +{value} diff --git a/test/runtime/samples/component-binding-reactive-property-no-extra-call/_config.js b/test/runtime/samples/component-binding-reactive-property-no-extra-call/_config.js new file mode 100644 index 0000000000..ae7b55e100 --- /dev/null +++ b/test/runtime/samples/component-binding-reactive-property-no-extra-call/_config.js @@ -0,0 +1,5 @@ +export default { + async test({ assert, component }) { + assert.equal(component.object_updates, 1); + }, +}; diff --git a/test/runtime/samples/component-binding-reactive-property-no-extra-call/main.svelte b/test/runtime/samples/component-binding-reactive-property-no-extra-call/main.svelte new file mode 100644 index 0000000000..768f8c22a9 --- /dev/null +++ b/test/runtime/samples/component-binding-reactive-property-no-extra-call/main.svelte @@ -0,0 +1,10 @@ + + +