You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime-puppeteer/samples/dynamic-element-custom-element/main.svelte

33 lines
528 B

<script>
class MyCustomElement extends HTMLElement {
constructor() {
super();
this._name = null;
}
/**
* @param {string} name
*/
set name(name) {
this._name = name;
this.render();
}
connectedCallback() {
this.render();
}
render() {
this.innerHTML = "Hello " + this._name + "!";
}
}
window.customElements.define("my-custom-element", MyCustomElement);
export let tag;
export let name;
</script>
<svelte:element this="{tag}" {name} id="a" />
<my-custom-element {name} id="b" />