22 lines
495 B
HTML
22 lines
495 B
HTML
<script>
|
|
class CustomElement extends HTMLElement {
|
|
constructor() {
|
|
super();
|
|
|
|
const shadow = this.attachShadow({ mode: 'open' });
|
|
const slot = document.createElement('slot');
|
|
const style = document.createElement('style');
|
|
style.textContent = `
|
|
:host {
|
|
text-decoration: underline;
|
|
}
|
|
`;
|
|
shadow.append(style, slot);
|
|
}
|
|
}
|
|
|
|
customElements.define('custom-element', CustomElement);
|
|
</script>
|
|
|
|
<custom-element>This should be underlined</custom-element>
|