From 5624c83403ad3e1032a72544be45de50c7bc0a05 Mon Sep 17 00:00:00 2001 From: wuls Date: Mon, 25 Mar 2024 15:10:26 +0800 Subject: [PATCH 1/3] fix bug --- packages/core/src/generators/solid/blocks.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/core/src/generators/solid/blocks.ts b/packages/core/src/generators/solid/blocks.ts index 14dd1abd33..08cdd4f4c9 100644 --- a/packages/core/src/generators/solid/blocks.ts +++ b/packages/core/src/generators/solid/blocks.ts @@ -49,12 +49,7 @@ export const blockToSolid = ({ } let str = ''; - - if (json.name === 'Fragment') { - str += '<'; - } else { - str += `<${json.name} `; - } + str += `<${json.name} `; if (json.name === 'Show' && json.meta.else) { str += `fallback={${blockToSolid({ component, json: json.meta.else as any, options })}}`; @@ -115,16 +110,16 @@ export const blockToSolid = ({ str += '>'; if (json.children) { str += json.children + .flatMap((item) => { + const Fragment = item.children.find((item) => item.name === 'Fragment'); + return Fragment ? Fragment.children : item; + }) .filter(filterEmptyTextNodes) .map((item) => blockToSolid({ component, json: item, options })) .join('\n'); } - - if (json.name === 'Fragment') { - str += ''; - } else { - str += ``; - } + // A -> F + str += ``; return str; }; From 1de8f80321a0686b677004b2b168dfd4cb0aff79 Mon Sep 17 00:00:00 2001 From: wuls Date: Mon, 25 Mar 2024 15:13:10 +0800 Subject: [PATCH 2/3] fix bug --- .changeset/famous-boats-fetch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/famous-boats-fetch.md diff --git a/.changeset/famous-boats-fetch.md b/.changeset/famous-boats-fetch.md new file mode 100644 index 0000000000..319da5ecd8 --- /dev/null +++ b/.changeset/famous-boats-fetch.md @@ -0,0 +1,5 @@ +--- +'@builder.io/mitosis': major +--- + +fix a bug 1330 From 4a49088721807c2d7e66530208b5b82393a6b920 Mon Sep 17 00:00:00 2001 From: wuls Date: Tue, 14 May 2024 11:23:47 +0800 Subject: [PATCH 3/3] fix: test --- packages/core/src/generators/solid/blocks.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/src/generators/solid/blocks.ts b/packages/core/src/generators/solid/blocks.ts index 08cdd4f4c9..35260df030 100644 --- a/packages/core/src/generators/solid/blocks.ts +++ b/packages/core/src/generators/solid/blocks.ts @@ -110,9 +110,12 @@ export const blockToSolid = ({ str += '>'; if (json.children) { str += json.children - .flatMap((item) => { + .map((item) => { const Fragment = item.children.find((item) => item.name === 'Fragment'); - return Fragment ? Fragment.children : item; + if (Fragment) { + item.children = [...Fragment.children]; + } + return item; }) .filter(filterEmptyTextNodes) .map((item) => blockToSolid({ component, json: item, options }))