diff --git a/packages/dom-manager/src/DOMElement.ts b/packages/dom-manager/src/DOMElement.ts index 3e04ac0..f791c87 100644 --- a/packages/dom-manager/src/DOMElement.ts +++ b/packages/dom-manager/src/DOMElement.ts @@ -157,13 +157,15 @@ export default class DOMElement { public data(key: string): string | null public data(key: string, value: string | null): this 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) } - 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') { - return this.item.style[key as any] + return this.item.style[key] } this.item.style[key as any] = value as string return this