diff --git a/src/runtime/internal/scheduler.ts b/src/runtime/internal/scheduler.ts
index 2f864743a2f4..04c1264ab1d2 100644
--- a/src/runtime/internal/scheduler.ts
+++ b/src/runtime/internal/scheduler.ts
@@ -73,8 +73,9 @@ function update($$) {
if ($$.fragment !== null) {
$$.update();
run_all($$.before_update);
- $$.fragment && $$.fragment.p($$.ctx, $$.dirty);
+ const dirty = $$.dirty;
$$.dirty = [-1];
+ $$.fragment && $$.fragment.p($$.ctx, dirty);
$$.after_update.forEach(add_render_callback);
}
diff --git a/test/runtime/samples/store-invalidation-while-update-1/_config.js b/test/runtime/samples/store-invalidation-while-update-1/_config.js
new file mode 100644
index 000000000000..d0361d2d2345
--- /dev/null
+++ b/test/runtime/samples/store-invalidation-while-update-1/_config.js
@@ -0,0 +1,44 @@
+export default {
+ html: `
+
+
+ simple
+
+ `,
+
+ async test({ assert, component, target, window }) {
+ const input = target.querySelector('input');
+ const button = target.querySelector('button');
+
+ const inputEvent = new window.InputEvent('input');
+ const clickEvent = new window.MouseEvent('click');
+
+ input.value = 'foo';
+ await input.dispatchEvent(inputEvent);
+
+ assert.htmlEqual(target.innerHTML, `
+
+ foo
+ foo
+
+ `);
+
+ await button.dispatchEvent(clickEvent);
+ assert.htmlEqual(target.innerHTML, `
+
+ foo
+ clicked
+
+ `);
+
+ input.value = 'bar';
+ await input.dispatchEvent(inputEvent);
+
+ assert.htmlEqual(target.innerHTML, `
+
+ bar
+ bar
+
+ `);
+ }
+};
\ No newline at end of file
diff --git a/test/runtime/samples/store-invalidation-while-update-1/main.svelte b/test/runtime/samples/store-invalidation-while-update-1/main.svelte
new file mode 100644
index 000000000000..f74808ee2ec0
--- /dev/null
+++ b/test/runtime/samples/store-invalidation-while-update-1/main.svelte
@@ -0,0 +1,20 @@
+
+
+
+{v}
+{$s}
+
diff --git a/test/runtime/samples/store-invalidation-while-update-2/_config.js b/test/runtime/samples/store-invalidation-while-update-2/_config.js
new file mode 100644
index 000000000000..422034bc11bd
--- /dev/null
+++ b/test/runtime/samples/store-invalidation-while-update-2/_config.js
@@ -0,0 +1,44 @@
+export default {
+ html: `
+
+ simple
+
+
+ `,
+
+ async test({ assert, component, target, window }) {
+ const input = target.querySelector('input');
+ const button = target.querySelector('button');
+
+ const inputEvent = new window.InputEvent('input');
+ const clickEvent = new window.MouseEvent('click');
+
+ input.value = 'foo';
+ await input.dispatchEvent(inputEvent);
+
+ assert.htmlEqual(target.innerHTML, `
+ foo
+ foo
+
+
+ `);
+
+ await button.dispatchEvent(clickEvent);
+ assert.htmlEqual(target.innerHTML, `
+ foo
+ clicked
+
+
+ `);
+
+ input.value = 'bar';
+ await input.dispatchEvent(inputEvent);
+
+ assert.htmlEqual(target.innerHTML, `
+ bar
+ bar
+
+
+ `);
+ }
+};
\ No newline at end of file
diff --git a/test/runtime/samples/store-invalidation-while-update-2/main.svelte b/test/runtime/samples/store-invalidation-while-update-2/main.svelte
new file mode 100644
index 000000000000..83e13742ceb6
--- /dev/null
+++ b/test/runtime/samples/store-invalidation-while-update-2/main.svelte
@@ -0,0 +1,20 @@
+
+
+{v}
+{$s}
+
+