feat: add shared q() qs() DOM helpers
This commit is contained in:
8
static/q.ts
Normal file
8
static/q.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export const q = <T extends Element>(container: HTMLElement, selector: string): T | null =>
|
||||
container.querySelector(selector) as T | null
|
||||
|
||||
export const qs = <T extends Element>(selector: string): T | null =>
|
||||
document.querySelector(selector) as T | null
|
||||
|
||||
export const dataset = (el: HTMLElement, key: string): string =>
|
||||
el.dataset[key] ?? ''
|
||||
Reference in New Issue
Block a user