From f8283fbc775d94d2ea081d06153cc1f9d89eea72 Mon Sep 17 00:00:00 2001 From: Nguyen Tran <88808276+ngtr6788@users.noreply.github.com> Date: Wed, 19 Jul 2023 07:55:27 -0400 Subject: [PATCH] fix: remove let variable from select binding dependencies (#8969) Fixes #2943 The issue linked above invalidates a variable that is not defined in + + + diff --git a/packages/svelte/test/runtime/samples/binding-select-from-let-2/_config.js b/packages/svelte/test/runtime/samples/binding-select-from-let-2/_config.js new file mode 100644 index 0000000000..125455819a --- /dev/null +++ b/packages/svelte/test/runtime/samples/binding-select-from-let-2/_config.js @@ -0,0 +1,25 @@ +export default { + html: ` + +

1

+ `, + + async test({ assert, component, target, window }) { + const select = target.querySelector('select'); + const options = target.querySelectorAll('option'); + + assert.equal(component.tasks_touched, 1); + + const change = new window.Event('change'); + options[1].selected = true; + await select.dispatchEvent(change); + + assert.equal(component.selected, options[1].value); + assert.equal(component.tasks_touched, 1); + } +}; diff --git a/packages/svelte/test/runtime/samples/binding-select-from-let-2/main.svelte b/packages/svelte/test/runtime/samples/binding-select-from-let-2/main.svelte new file mode 100644 index 0000000000..3c21eba829 --- /dev/null +++ b/packages/svelte/test/runtime/samples/binding-select-from-let-2/main.svelte @@ -0,0 +1,19 @@ + + + + + +

{tasks_touched}

diff --git a/packages/svelte/test/runtime/samples/binding-select-from-let/Parent.svelte b/packages/svelte/test/runtime/samples/binding-select-from-let/Parent.svelte new file mode 100644 index 0000000000..565c3bc6b7 --- /dev/null +++ b/packages/svelte/test/runtime/samples/binding-select-from-let/Parent.svelte @@ -0,0 +1,6 @@ + + + + diff --git a/packages/svelte/test/runtime/samples/binding-select-from-let/_config.js b/packages/svelte/test/runtime/samples/binding-select-from-let/_config.js new file mode 100644 index 0000000000..30f42a2251 --- /dev/null +++ b/packages/svelte/test/runtime/samples/binding-select-from-let/_config.js @@ -0,0 +1,21 @@ +export default { + html: ` + + `, + + async test({ assert, component, target, window }) { + const select = target.querySelector('select'); + const options = target.querySelectorAll('option'); + + const change = new window.Event('change'); + options[1].selected = true; + await select.dispatchEvent(change); + + assert.equal(component.selected, options[1].value); + } +}; diff --git a/packages/svelte/test/runtime/samples/binding-select-from-let/main.svelte b/packages/svelte/test/runtime/samples/binding-select-from-let/main.svelte new file mode 100644 index 0000000000..494653bb4c --- /dev/null +++ b/packages/svelte/test/runtime/samples/binding-select-from-let/main.svelte @@ -0,0 +1,12 @@ + + + + +