Refactor and minor fixes

This commit is contained in:
Andras Schmelczer 2022-09-21 21:57:58 +02:00
parent 2dc9c45642
commit fe75f9af88
No known key found for this signature in database
GPG key ID: 0EA1BC97D0AB076E
31 changed files with 187 additions and 193 deletions

View file

@ -3,8 +3,11 @@ import { PageElement } from '../page-element';
import { generate } from './main.html';
export class Main extends PageElement {
constructor(...children: Array<PageElement>) {
super(createElement(generate()), children);
children.forEach((c) => this.attachElement(c));
constructor(...children: Array<PageElement | string>) {
const actualChildren = children.map((c) =>
c instanceof PageElement ? c : new PageElement(createElement(c))
);
super(createElement(generate()), actualChildren);
actualChildren.forEach((c) => this.attachElement(c));
}
}