mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat: use anchor API for html elements (#174)
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user