From aad75fd7c4aecc752b2282d0af40bcdbcc52c239 Mon Sep 17 00:00:00 2001 From: daiwei Date: Fri, 25 Apr 2025 15:08:19 +0800 Subject: [PATCH] wip: refactor --- .../__tests__/ssrComponent.spec.ts | 8 +- .../__tests__/ssrFallthroughAttrs.spec.ts | 2 +- .../__tests__/ssrInjectCssVars.spec.ts | 2 +- .../__tests__/ssrSlotOutlet.spec.ts | 2 +- .../__tests__/ssrTransitionGroup.spec.ts | 4 +- .../compiler-ssr/__tests__/ssrVIf.spec.ts | 24 +- .../compiler-ssr/__tests__/ssrVModel.spec.ts | 2 +- .../compiler-ssr/src/ssrCodegenTransform.ts | 11 +- .../src/transforms/ssrTransformComponent.ts | 11 +- .../compiler-ssr/src/transforms/ssrVIf.ts | 6 +- .../runtime-core/__tests__/hydration.spec.ts | 12 +- packages/runtime-core/src/hydration.ts | 14 +- packages/runtime-core/src/index.ts | 4 - .../runtime-vapor/__tests__/hydration.spec.ts | 1211 +++++++++-------- .../src/apiCreateDynamicComponent.ts | 13 +- packages/runtime-vapor/src/apiCreateIf.ts | 15 +- packages/runtime-vapor/src/block.ts | 21 +- packages/runtime-vapor/src/dom/hydration.ts | 3 +- packages/runtime-vapor/src/dom/node.ts | 38 +- .../__tests__/ssrAttrFallthrough.spec.ts | 2 +- .../__tests__/ssrDynamicComponent.spec.ts | 14 +- .../server-renderer/__tests__/ssrSlot.spec.ts | 14 +- packages/server-renderer/src/render.ts | 1 - packages/shared/src/domAnchors.ts | 30 + packages/shared/src/index.ts | 1 + 25 files changed, 760 insertions(+), 705 deletions(-) create mode 100644 packages/shared/src/domAnchors.ts diff --git a/packages/compiler-ssr/__tests__/ssrComponent.spec.ts b/packages/compiler-ssr/__tests__/ssrComponent.spec.ts index 7459cb492..1bae37c0f 100644 --- a/packages/compiler-ssr/__tests__/ssrComponent.spec.ts +++ b/packages/compiler-ssr/__tests__/ssrComponent.spec.ts @@ -39,6 +39,7 @@ describe('ssr: components', () => { return function ssrRender(_ctx, _push, _parent, _attrs) { _ssrRenderVNode(_push, _createVNode(_resolveDynamicComponent("foo"), _mergeProps({ prop: "b" }, _attrs), null), _parent) + _push(\`\`) }" `) @@ -49,6 +50,7 @@ describe('ssr: components', () => { return function ssrRender(_ctx, _push, _parent, _attrs) { _ssrRenderVNode(_push, _createVNode(_resolveDynamicComponent(_ctx.foo), _mergeProps({ prop: "b" }, _attrs), null), _parent) + _push(\`\`) }" `) }) @@ -245,7 +247,7 @@ describe('ssr: components', () => { _push(\`\`) }) _push(\`\`) - _push(\`\`) + _push(\`\`) } else { _push(\`\`) } @@ -269,7 +271,7 @@ describe('ssr: components', () => { _push(\`\`) }) _push(\`\`) - _push(\`\`) + _push(\`\`) } else { _push(\`\`) } @@ -363,7 +365,7 @@ describe('ssr: components', () => { _push(\`\`) if (false) { _push(\`\`) - _push(\`\`) + _push(\`\`) } else { _push(\`\`) } diff --git a/packages/compiler-ssr/__tests__/ssrFallthroughAttrs.spec.ts b/packages/compiler-ssr/__tests__/ssrFallthroughAttrs.spec.ts index a83797900..712c09d09 100644 --- a/packages/compiler-ssr/__tests__/ssrFallthroughAttrs.spec.ts +++ b/packages/compiler-ssr/__tests__/ssrFallthroughAttrs.spec.ts @@ -29,7 +29,7 @@ describe('ssr: attrs fallthrough', () => { _push(\`\`) if (true) { _push(\`
\`) - _push(\`\`) + _push(\`\`) } else { _push(\`\`) } diff --git a/packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts b/packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts index 3eef5a777..0666e8949 100644 --- a/packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts +++ b/packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts @@ -70,7 +70,7 @@ describe('ssr: inject