From 6eb91f57a6b97d691be4720061ba4dcdd0520e6b Mon Sep 17 00:00:00 2001 From: Avior Date: Mon, 8 Feb 2021 12:17:41 +0100 Subject: [PATCH] Added Auto completion :D (#15) Signed-off-by: Florian BOUILLON --- packages/dom-manager/src/DOMElement.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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