exclude internal props from spread attributes

pull/9384/head
Rich Harris 3 years ago
parent 51394a4834
commit 6fff77d9c4

@ -2843,6 +2843,8 @@ export function spread_attributes(dom, prev, attrs, css_hash) {
if (!setters) map_set(setters_cache, dom.nodeName, (setters = get_setters(dom)));
for (const key in next) {
if (key.startsWith('$$')) continue;
let value = next[key];
if (has_hash && key === 'class') {
if (value) value += ' ';

@ -0,0 +1,7 @@
<script>
let { ...stuff } = $props();
</script>
<button {...stuff} on:click>
<slot></slot>
</button>

@ -0,0 +1,13 @@
import { test } from '../../test';
export default test({
html: `<button>clicks: 0</button>`,
async test({ assert, target }) {
const button = target.querySelector('button');
button?.click();
await Promise.resolve();
assert.htmlEqual(target.innerHTML, '<button>clicks: 1</button>');
}
});

@ -0,0 +1,13 @@
<script>
import Button from './Button.svelte';
let count = $state(0);
function increment() {
count += 1;
}
</script>
<Button on:click={increment}>
clicks: {count}
</Button>
Loading…
Cancel
Save