mirror of https://github.com/sveltejs/svelte
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 #12052pull/12061/head
parent
c3da6a491f
commit
a1b6cc68d9
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"svelte": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: handle `is` attribute on elements with spread
|
@ -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']);
|
||||||
|
}
|
||||||
|
});
|
@ -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>
|
Loading…
Reference in new issue