-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle
is
attribute on elements with spread (#12056)
The `is` attribute is special and always needs to be part of the static template string, or else it wouldn't be taken into account on initialization fixes #12052
- Loading branch information
1 parent
c3da6a4
commit a1b6cc6
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte": patch | ||
--- | ||
|
||
fix: handle `is` attribute on elements with spread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/svelte/tests/runtime-runes/samples/element-is-attribute/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
mode: ['client'], | ||
test({ assert, target, logs }) { | ||
const [b1, b2] = target.querySelectorAll('button'); | ||
|
||
b1.click(); | ||
flushSync(); | ||
assert.deepEqual(logs, ['works']); | ||
|
||
b2.click(); | ||
flushSync(); | ||
assert.deepEqual(logs, ['works', 'works']); | ||
} | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/svelte/tests/runtime-runes/samples/element-is-attribute/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script lang="ts" context="module"> | ||
if (!customElements.get('x-button')) { | ||
class XButton extends HTMLButtonElement { | ||
connectedCallback() { | ||
this.addEventListener('click', () => console.log('works')); | ||
} | ||
} | ||
customElements.define('x-button', XButton, { extends: 'button' }); | ||
} | ||
</script> | ||
|
||
<script lang="ts"> | ||
let { ...props } = $props(); | ||
</script> | ||
|
||
<button is="x-button">click me</button> | ||
<button {...props} is="x-button">click me</button> |