From 89c4cf393f037a0e967f00f1cae341d486a3f178 Mon Sep 17 00:00:00 2001 From: Ahmad Date: Tue, 6 Feb 2024 22:48:28 +0200 Subject: [PATCH] fix: set `open` binding value in `
` (#10413) * fix: set initial value for `open` binding in `
` * accurate desc --- .changeset/strange-apricots-happen.md | 5 +++++ packages/svelte/src/compiler/phases/bindings.js | 1 + .../samples/details-binding-initial/_config.js | 11 +++++++++++ .../samples/details-binding-initial/main.svelte | 8 ++++++++ 4 files changed, 25 insertions(+) create mode 100644 .changeset/strange-apricots-happen.md create mode 100644 packages/svelte/tests/runtime-runes/samples/details-binding-initial/_config.js create mode 100644 packages/svelte/tests/runtime-runes/samples/details-binding-initial/main.svelte diff --git a/.changeset/strange-apricots-happen.md b/.changeset/strange-apricots-happen.md new file mode 100644 index 0000000000..d61dfb5149 --- /dev/null +++ b/.changeset/strange-apricots-happen.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: set `open` binding value in `
` diff --git a/packages/svelte/src/compiler/phases/bindings.js b/packages/svelte/src/compiler/phases/bindings.js index d8f04e1732..820c66d886 100644 --- a/packages/svelte/src/compiler/phases/bindings.js +++ b/packages/svelte/src/compiler/phases/bindings.js @@ -175,6 +175,7 @@ export const binding_properties = { textContent: {}, open: { event: 'toggle', + type: 'set', valid_elements: ['details'] }, value: { diff --git a/packages/svelte/tests/runtime-runes/samples/details-binding-initial/_config.js b/packages/svelte/tests/runtime-runes/samples/details-binding-initial/_config.js new file mode 100644 index 0000000000..d0ecf31923 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/details-binding-initial/_config.js @@ -0,0 +1,11 @@ +import { ok, test } from '../../test'; + +export default test({ + test({ assert, target }) { + const details_el = target.querySelector('details'); + + ok(details_el); + + assert.strictEqual(details_el.open, true); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/details-binding-initial/main.svelte b/packages/svelte/tests/runtime-runes/samples/details-binding-initial/main.svelte new file mode 100644 index 0000000000..fda553038e --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/details-binding-initial/main.svelte @@ -0,0 +1,8 @@ + + +
+ Details + ... +