Skip to content

Commit 7b72bf0

Browse files
committed
add type safety in Component#css() implementation
1 parent 9b0e182 commit 7b72bf0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,16 @@ export class Component<T extends HTMLElement = HTMLElement> extends BaseComponen
9696

9797
public css(...args: [string, string] | [string, string, boolean] | [Record<string, string>]): typeof this {
9898
if (args.length === 2 || args.length === 3) {
99-
const [name, value, priority] = args;
99+
const name: string = args[0],
100+
value: string = args[1],
101+
priority: boolean = args[2] ?? false;
100102
this.element.style.setProperty(name, value, priority ? "important" : void 0);
101103
}
102-
else for (const [name, value] of Object.entries(args[0]))
103-
this.css(name, value);
104+
else {
105+
const properties: Record<string, string> = args[0];
106+
for (const [name, value] of Object.entries(properties))
107+
this.css(name, value);
108+
}
104109
return this;
105110
}
106111

0 commit comments

Comments
 (0)