mirror of https://github.com/sveltejs/svelte
fix: allow using typescript in `customElement.extend` option (#16001)
Closes #15372 --------- Co-authored-by: Dominik G. <dominik.goepel@gmx.de>pull/16006/head
parent
add0c6a987
commit
fbb6444fd8
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: allow using typescript in `customElement.extend` option
|
@ -0,0 +1,19 @@
|
|||||||
|
import { test } from '../../assert';
|
||||||
|
const tick = () => Promise.resolve();
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target }) {
|
||||||
|
target.innerHTML = '<custom-element name="world"></custom-element>';
|
||||||
|
await tick();
|
||||||
|
/** @type {any} */
|
||||||
|
const el = target.querySelector('custom-element');
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
el.shadowRoot.innerHTML,
|
||||||
|
`
|
||||||
|
<p>name: world</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
assert.equal(el.test, `test`);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,14 @@
|
|||||||
|
<svelte:options customElement={{
|
||||||
|
tag: "custom-element",
|
||||||
|
extend: (customClass)=>{
|
||||||
|
return class extends customClass{
|
||||||
|
public test: string = "test";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}}/>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
let { name } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>name: {name}</p>
|
Loading…
Reference in new issue