Fix DynamicBorder crash when theme not initialized
Make DynamicBorder defensive against undefined theme by checking at render time instead of relying on default parameter closure.
This commit is contained in:
@@ -7,8 +7,10 @@ import { theme } from "../theme/theme.js";
|
|||||||
export class DynamicBorder implements Component {
|
export class DynamicBorder implements Component {
|
||||||
private color: (str: string) => string;
|
private color: (str: string) => string;
|
||||||
|
|
||||||
constructor(color: (str: string) => string = (str) => theme.fg("border", str)) {
|
constructor(color?: (str: string) => string) {
|
||||||
this.color = color;
|
// Use provided color function, or default to theme border color
|
||||||
|
// Theme may not be initialized at construction time, so we check at render time
|
||||||
|
this.color = color ?? ((str) => (theme ? theme.fg("border", str) : str));
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidate(): void {
|
invalidate(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user