| 2 | import { Component, css, html } from "../lib/component"; |
| 3 | |
| 4 | export default class TestingRef extends Component { |
| 5 | ref?: HTMLElement; |
| 6 | |
| 7 | static css = css` |
| 8 | p { |
| 9 | background: lightblue; |
| 10 | } |
| 11 | |
| 12 | ::slotted(p) { |
| 13 | background: lightcoral; |
| 14 | } |
| 15 | |
| 16 | .someclass::after { |
| 17 | display: block; |
| 18 | content: "Something"; |
| 19 | } |
| 20 | `; |
| 21 | |
| 22 | isDisabled = signal(false); |
| 23 | count = signal(0); |
| 24 | |
| 25 | get header() { |
| 26 | return html` <h1>${this.count.value}</h1> `; |
| 27 | } |
| 28 | |
| 29 | connectedCallback(): void { |
| 30 | super.connectedCallback(); |
| 31 | |
| 32 | setInterval(() => this.count.value++, 1000); |
| 33 | } |
| 34 | |
| 35 | squeak = (event: MouseEvent) => { |
| 36 | this.isDisabled.value = !this.isDisabled.value; |
| 37 | (event.target as HTMLButtonElement).dispatchEvent( |
| 38 | new CustomEvent("squeak-er", { bubbles: true }), |
| 39 | ); |
| 40 | }; |
| 41 | |
| 42 | render() { |
| 43 | return html` |
| 44 | <div |
| 45 | ref=${(el: HTMLDivElement) => (this.ref = el)} |
| 46 | onsqueak-er=${() => console.log("squeak")} |
| 47 | aria-label=${null} |
| 48 | > |
| 49 | ${this.header} |
| 50 | <p .dataset=${{ foo: "bar", num: 42 }}>lorem</p> |
| 51 | <slot></slot> |
| 52 | <button .disabled=${this.isDisabled.value}>Disabled?</button> |
| 53 | <button onclick=${this.squeak}>squeak</button> |
| 54 | </div> |
| 55 | `; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | declare global { |
| 60 | interface HTMLElementTagNameMap { |
nothing calls this directly
no outgoing calls
no test coverage detected