fix(runtime): validate invalid foreground color props

This commit is contained in:
Yunfei He
2026-06-13 03:27:48 +08:00
committed by GitHub
parent d1fe39f96c
commit 5d29240df9
6 changed files with 124 additions and 20 deletions
@@ -875,6 +875,46 @@ test('foreground color="bold" (a chalk modifier) bolds, does NOT throw', async (
expect(lastFrame()).toContain("\x1b[1m");
});
// Foreground colors have their own invalid named-color edge: some chalk keys
// exist but are not callable color/modifier methods. Ink calls chalk[color] in
// that case and crashes; vue-tui validates during render so the app rejects
// through ErrorOverview instead of letting paint wedge the scheduler.
test('foreground color="level" throws (Ink parity, recoverable channel)', async ({ expect }) => {
await expect(
render(
defineComponent(() => () => (
<Box alignSelf="flex-start">
<Text color="level">Hi</Text>
</Box>
)),
{ columns: 100 },
),
).rejects.toThrow(/color/i);
});
for (const borderColorProp of [
"borderColor",
"borderTopColor",
"borderBottomColor",
"borderLeftColor",
"borderRightColor",
] as const) {
test(`<Box ${borderColorProp}="level"> throws (Ink parity, recoverable channel)`, async ({
expect,
}) => {
await expect(
render(
defineComponent(() => () => (
<Box borderStyle="single" {...{ [borderColorProp]: "level" }} alignSelf="flex-start">
<Text>Hi</Text>
</Box>
)),
{ columns: 100 },
),
).rejects.toThrow(/color/i);
});
}
// --- A12 gating: vue must throw WHERE Ink colorizes, and NOT elsewhere ---
//
// Ink throws on a chalk-modifier-name bg LAZILY — only when it actually