Skip to content

Commit 48ab766

Browse files
author
kai
committed
Accept undefined & null
1 parent be9ad42 commit 48ab766

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/BaseComponent.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,17 @@ export abstract class BaseComponent<T extends Element> {
5656
/**
5757
* Insert component after the last child
5858
*/
59-
public append(component: BaseComponent<any>) {
59+
public append(component?: BaseComponent<any> | null) {
60+
if (!component) return this;
6061
this.element.appendChild(component.element);
6162
return this;
6263
}
6364

6465
/**
6566
* Insert component before the first child
6667
*/
67-
public prepend(component: BaseComponent<any>) {
68+
public prepend(component?: BaseComponent<any> | null) {
69+
if (!component) return this;
6870
this.element.prepend(component.element);
6971
return this;
7072
}

0 commit comments

Comments
 (0)