feat: use anchor API for html elements (#174)

This commit is contained in:
Wesley Luyten
2025-11-07 14:33:10 -06:00
committed by GitHub
parent 8d477a33a4
commit 4a2d580bb3
16 changed files with 191 additions and 215 deletions
+8
View File
@@ -27,6 +27,8 @@ export class ButtonElement extends HTMLElement {
static getTemplateHTML: typeof getTemplateHTML = getTemplateHTML;
static observedAttributes: string[] = ['commandfor'];
constructor() {
super();
@@ -46,6 +48,12 @@ export class ButtonElement extends HTMLElement {
this.addEventListener('keydown', this);
}
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void {
if (name === 'commandfor') {
this.style.setProperty('anchor-name', `--${newValue}`);
}
}
handleEvent(event: Event): void {
const { type } = event;
if (type === 'keydown') {