mirror of https://github.com/sveltejs/svelte
fix: recognize all custom element prop definitions (#14084)
We didn't account for the `$props` rune being writtin in a way that makes some props unknown, and they would only be visible through the `customElement.props` definition. This changes the iteration to account for that and also adds a note to the documentation that you need to list out the properties explicitly. fixes #13785pull/14100/head
parent
6a2c28c590
commit
7d11fa8da2
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: recognize all custom element prop definitions
|
@ -0,0 +1,21 @@
|
||||
import { test } from '../../assert';
|
||||
const tick = () => Promise.resolve();
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
target.innerHTML = '<custom-element foo-bar="1" bar="2" b-az="3"></custom-element>';
|
||||
await tick();
|
||||
|
||||
/** @type {any} */
|
||||
const el = target.querySelector('custom-element');
|
||||
|
||||
assert.htmlEqual(
|
||||
el.shadowRoot.innerHTML,
|
||||
`
|
||||
<p>1</p>
|
||||
<p>2</p>
|
||||
<p>3</p>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,14 @@
|
||||
<svelte:options
|
||||
customElement={{
|
||||
tag: "custom-element",
|
||||
props: { foo: { attribute: 'foo-bar' } },
|
||||
}}
|
||||
/>
|
||||
|
||||
<script>
|
||||
let { bar, 'b-az': baz, ...rest } = $props();
|
||||
</script>
|
||||
|
||||
<p>{rest.foo}</p>
|
||||
<p>{bar}</p>
|
||||
<p>{baz}</p>
|
@ -0,0 +1,14 @@
|
||||
<svelte:options
|
||||
customElement={{
|
||||
tag: "my-widget",
|
||||
props: { foo: { attribute: 'foo-bar' } },
|
||||
}}
|
||||
/>
|
||||
|
||||
<script>
|
||||
let { bar, 'b-az': baz, ...rest } = $props();
|
||||
</script>
|
||||
|
||||
<p>{rest.foo}</p>
|
||||
<p>{bar}</p>
|
||||
<p>{baz}</p>
|
Loading…
Reference in new issue