mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-27 06:52:27 +08:00
31 lines
845 B
TypeScript
31 lines
845 B
TypeScript
import Component, { TypedComponent } from "../../components/component.js";
|
|
import BasicWidget, { TypedBasicWidget } from "../basic_widget.js";
|
|
|
|
export default class Container<T extends TypedComponent<any>> extends TypedBasicWidget<T> {
|
|
|
|
doRender() {
|
|
this.$widget = $(`<div>`);
|
|
this.renderChildren();
|
|
}
|
|
|
|
renderChildren() {
|
|
for (const widget of this.children) {
|
|
if (!("render" in widget)) {
|
|
throw "Non-renderable widget encountered.";
|
|
}
|
|
|
|
const typedWidget = widget as unknown as TypedBasicWidget<any>;
|
|
|
|
try {
|
|
if ("render" in widget) {
|
|
this.$widget.append(typedWidget.render());
|
|
}
|
|
|
|
} catch (e: any) {
|
|
typedWidget.logRenderingError(e);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|