fix: handle null/undefined Text children without crashing yoga

Guard flattenLeaves and renderTextWithInlineStyles to skip comment
nodes (produced by Vue for null/undefined children) and return empty
strings for childless text nodes. Also guard bindTextMeasure to return
zero dimensions for empty text. Expand TuiInlineNode to include
TuiComment since Vue inserts comments into text containers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yunfei He
2026-05-26 00:01:32 +08:00
parent 9e0bdfcb97
commit fa60d12f5a
5 changed files with 15 additions and 6 deletions
@@ -24,7 +24,7 @@ test("CJK wide characters render without corruption", async () => {
// --- Ink text tests ---
test.skip("<Text> with undefined children — crashes yoga measure", async () => {
test("<Text> with undefined children", async () => {
const { lastFrame } = await render(
defineComponent(() => () => <Text />),
{ columns: 100 },
@@ -32,7 +32,7 @@ test.skip("<Text> with undefined children — crashes yoga measure", async () =>
expect(lastFrame()).toBe("");
});
test.skip("<Text> with null children — crashes yoga measure", async () => {
test("<Text> with null children", async () => {
const { lastFrame } = await render(
defineComponent(() => () => <Text>{null}</Text>),
{ columns: 100 },
@@ -169,7 +169,7 @@ test("remeasure text when text is changed", async () => {
expect(lastFrame()).toBe("abcx");
});
test.skip("remeasure text when text nodes are changed — null child crashes yoga", async () => {
test("remeasure text when text nodes are changed", async () => {
const add = shallowRef(false);
const { lastFrame } = await render(
defineComponent(() => () => (