1
0
mirror of https://github.com/dzeiocom/libs.git synced 2025-04-23 11:22:15 +00:00

Added Auto completion :D (#15)

Signed-off-by: Florian BOUILLON <florian.bouillon@delta-wings.net>
This commit is contained in:
Florian Bouillon 2021-02-08 12:17:41 +01:00 committed by GitHub
parent 799c0269c2
commit 6eb91f57a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,13 +157,15 @@ export default class DOMElement<T extends HTMLElement = HTMLElement> {
public data(key: string): string | null public data(key: string): string | null
public data(key: string, value: string | null): this public data(key: string, value: string | null): this
public data(key: string, value?: string | null): this | string | null { public data(key: string, value?: string | null): this | string | null {
// @ts-ignore // @ts-ignore Ignore because data-elements aren't valid attrs for an HTMLElement
return this.attr(`data-${key}`, value) return this.attr(`data-${key}`, value)
} }
public style(key: string, value?: string | number) { public style(key: keyof CSSStyleDeclaration): CSSStyleDeclaration[typeof key]
public style(key: keyof CSSStyleDeclaration, value: CSSStyleDeclaration[typeof key]): this
public style(key: keyof CSSStyleDeclaration, value?: CSSStyleDeclaration[typeof key]) {
if (typeof value === 'undefined') { if (typeof value === 'undefined') {
return this.item.style[key as any] return this.item.style[key]
} }
this.item.style[key as any] = value as string this.item.style[key as any] = value as string
return this return this