Skip to content

test vapor(DO NOT MERGE) #13383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 52 commits into
base: vapor
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
9ab8e4c
chore: update lockfile
edison1105 Apr 1, 2025
53564e0
fix(runtime-vapor): use slot fallback on initial render
edison1105 Apr 2, 2025
e5dd701
feat(vapor/hydration): handle component with anchor insertion
edison1105 Apr 21, 2025
9c30fd4
wip: save
edison1105 Apr 22, 2025
d8443d3
wip: refactor
edison1105 Apr 22, 2025
3108d91
refactor: skip dynamic anchors and empty text nodes
edison1105 Apr 23, 2025
1248172
wip: save
edison1105 Apr 23, 2025
25b8fbe
refactor: add enableHydrationNodeLookup and disableHydrationNodeLooku…
edison1105 Apr 23, 2025
3e7f093
chore: dont process text/comment node as dynamic
edison1105 Apr 23, 2025
04eadd8
wip: refactor
edison1105 Apr 23, 2025
b5762b5
wip: add tests + skip fragment end anchor
edison1105 Apr 24, 2025
38d4889
wip: hydrate v-if
edison1105 Apr 24, 2025
e9c9e49
wip: refactor hydration for v-if
edison1105 Apr 24, 2025
612cde7
wip: test hydrate v-if in PROD
edison1105 Apr 25, 2025
4d8284b
test: update
edison1105 Apr 25, 2025
34b9a4b
wip: hydation for dynamic component
edison1105 Apr 25, 2025
aad75fd
wip: refactor
edison1105 Apr 25, 2025
e6e0160
wip: v-for hydration
edison1105 Apr 25, 2025
7a842ab
wip: refactor
edison1105 Apr 26, 2025
ca34d4a
wip: add more tests
edison1105 Apr 26, 2025
42a421a
wip: hydration for slots
edison1105 Apr 26, 2025
2f00264
fix(compiler-vapor): move `next`, `child` and `nthChild` before setI…
zhiyuanzmj Apr 27, 2025
700f49e
wip: hydration for slots
edison1105 Apr 27, 2025
e5399c3
wip: vdom interop
edison1105 Apr 28, 2025
4253b0c
wip: update
edison1105 Apr 28, 2025
d281d62
wip: vdom hydration interop
edison1105 Apr 29, 2025
ea34f2f
wip: vdom interop
edison1105 Apr 29, 2025
3e69504
fix(compiler-vapor): properly handle static ref in inline mode
edison1105 Apr 29, 2025
a9496de
test: more tests
edison1105 Apr 29, 2025
d776a26
chore: tweaks
edison1105 Apr 30, 2025
9477b91
fix(vapor): special handling vapor props in vdom interop
edison1105 May 26, 2025
ebd32e6
chore: Merge branch 'edison/fix/vdomInteropWithProps' into edison/tes…
edison1105 May 26, 2025
86a6604
wip: handling vapor props
edison1105 May 26, 2025
bd701f2
fix(vapor): ensure props are shallow reactive to prevent DEV warnings
edison1105 May 26, 2025
29b3133
Merge branch 'edison/vapor/vdomInteropProps' into edison/testVapor
edison1105 May 26, 2025
594ffae
wip: handling vapor props
edison1105 May 26, 2025
b0df00a
fix(runtime-vapor): should not warn invalid watch source when directl…
edison1105 May 26, 2025
d751b6c
Merge branch 'edison/vapor/vdomInteropProps' into edison/testVapor
edison1105 May 27, 2025
8a6382c
fix(compiler-vapor): properly locate last if node
edison1105 May 28, 2025
cbfc289
Merge branch 'edison/fix/slotAndIfError' into edison/testVapor
edison1105 May 28, 2025
584c04f
feat(compiler-vapor): resolve implicitly self-referencing component
edison1105 May 28, 2025
bc9ff3f
Merge branch 'edison/fix/resolveComponent' into edison/testVapor
edison1105 May 29, 2025
3a39bc8
chore: update
edison1105 May 29, 2025
dde7076
feat(compiler-vapor): add support for forwarded slots
edison1105 May 29, 2025
a952b03
test: add tests
edison1105 May 29, 2025
c23d635
chore: update
edison1105 May 30, 2025
3a3fcda
Merge branch 'edison/feat/fowardedSlots' into edison/testVapor
edison1105 May 30, 2025
187396d
Merge branch 'edison/fix/vaporRenderSlotfallback' into edison/testVapor
edison1105 May 30, 2025
3896780
fix(vdomInterop): handle forwarded vapor slots during render VDOM slot
edison1105 May 30, 2025
023b005
chore: update
edison1105 May 30, 2025
8f29088
wip: refactor
edison1105 Jun 6, 2025
d0d5c3e
chore: Merge branch 'edison/feat/setScopeId' into edison/testVapor
edison1105 Jun 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages-private/vapor-e2e-test/interop/VaporComp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const slotProp = ref('slot prop')
change slot prop
</button>
<div class="vdom-slot-in-vapor-default">
#default: <slot :foo="slotProp" />
#default:
<slot :foo="slotProp" />
</div>
<div class="vdom-slot-in-vapor-test">
#test: <slot name="test">fallback content</slot>
Expand All @@ -40,7 +41,7 @@ const slotProp = ref('slot prop')
>
Toggle default slot to vdom
</button>
<VdomComp :msg="msg">
<VdomComp :msg="msg" class="foo">
<template #default="{ foo }" v-if="passSlot">
<div>slot prop: {{ foo }}</div>
<div>component prop: {{ msg }}</div>
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
createTransformContext,
traverseNode,
createStructuralDirectiveTransform,
getSelfName,
type NodeTransform,
type StructuralDirectiveTransform,
type DirectiveTransform,
Expand Down
8 changes: 6 additions & 2 deletions packages/compiler-core/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ export interface TransformContext
filters?: Set<string>
}

export function getSelfName(filename: string): string | null {
const nameMatch = filename.replace(/\?.*$/, '').match(/([^/\\]+)\.\w+$/)
return nameMatch ? capitalize(camelize(nameMatch[1])) : null
}

export function createTransformContext(
root: RootNode,
{
Expand Down Expand Up @@ -150,11 +155,10 @@ export function createTransformContext(
compatConfig,
}: TransformOptions,
): TransformContext {
const nameMatch = filename.replace(/\?.*$/, '').match(/([^/\\]+)\.\w+$/)
const context: TransformContext = {
// options
filename,
selfName: nameMatch && capitalize(camelize(nameMatch[1])),
selfName: getSelfName(filename),
prefixIdentifiers,
hoistStatic,
hmr,
Expand Down
9 changes: 7 additions & 2 deletions packages/compiler-ssr/__tests__/ssrComponent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(\`<!--dynamic-component-->\`)
}"
`)

Expand All @@ -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(\`<!--dynamic-component-->\`)
}"
`)
})
Expand Down Expand Up @@ -244,7 +246,8 @@ describe('ssr: components', () => {
_ssrRenderList(list, (i) => {
_push(\`<span\${_scopeId}></span>\`)
})
_push(\`<!--]--></div>\`)
_push(\`<!--]--><!--for--></div>\`)
_push(\`<!--if-->\`)
} else {
_push(\`<!---->\`)
}
Expand All @@ -267,7 +270,8 @@ describe('ssr: components', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<span\${_scopeId}></span>\`)
})
_push(\`<!--]--></div>\`)
_push(\`<!--]--><!--for--></div>\`)
_push(\`<!--if-->\`)
} else {
_push(\`<!---->\`)
}
Expand Down Expand Up @@ -361,6 +365,7 @@ describe('ssr: components', () => {
_push(\`\`)
if (false) {
_push(\`<div\${_scopeId}></div>\`)
_push(\`<!--if-->\`)
} else {
_push(\`<!---->\`)
}
Expand Down
46 changes: 46 additions & 0 deletions packages/compiler-ssr/__tests__/ssrElement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,50 @@ describe('ssr: element', () => {
`)
})
})

describe('dynamic anchor', () => {
test('two consecutive components', () => {
expect(
getCompiledString(`
<div>
<div/>
<Comp1/>
<Comp2/>
<div/>
</div>
`),
).toMatchInlineSnapshot(`
"\`<div><div></div>\`)
_push(_ssrRenderComponent(_component_Comp1, null, null, _parent))
_push(\`<!--[[-->\`)
_push(_ssrRenderComponent(_component_Comp2, null, null, _parent))
_push(\`<!--]]--><div></div></div>\`"
`)
})

test('multiple consecutive components', () => {
expect(
getCompiledString(`
<div>
<div/>
<Comp1/>
<Comp2/>
<Comp3/>
<Comp4/>
<div/>
</div>
`),
).toMatchInlineSnapshot(`
"\`<div><div></div>\`)
_push(_ssrRenderComponent(_component_Comp1, null, null, _parent))
_push(\`<!--[[-->\`)
_push(_ssrRenderComponent(_component_Comp2, null, null, _parent))
_push(\`<!--]]--><!--[[-->\`)
_push(_ssrRenderComponent(_component_Comp3, null, null, _parent))
_push(\`<!--]]-->\`)
_push(_ssrRenderComponent(_component_Comp4, null, null, _parent))
_push(\`<div></div></div>\`"
`)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('ssr: attrs fallthrough', () => {
_push(\`<!--[-->\`)
if (true) {
_push(\`<div></div>\`)
_push(\`<!--if-->\`)
} else {
_push(\`<!---->\`)
}
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ describe('ssr: inject <style vars>', () => {
const _cssVars = { style: { color: _ctx.color }}
if (_ctx.ok) {
_push(\`<div\${_ssrRenderAttrs(_mergeProps(_attrs, _cssVars))}></div>\`)
_push(\`<!--if-->\`)
} else {
_push(\`<!--[--><div\${
_ssrRenderAttrs(_cssVars)
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-ssr/__tests__/ssrSlotOutlet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ describe('ssr: <slot>', () => {
return function ssrRender(_ctx, _push, _parent, _attrs) {
if (true) {
_ssrRenderSlotInner(_ctx.$slots, "default", {}, null, _push, _parent, null, true)
_push(\`<!--if-->\`)
} else {
_push(\`<!---->\`)
}
Expand Down
13 changes: 9 additions & 4 deletions packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('transition-group', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<div></div>\`)
})
_push(\`<!--]-->\`)
_push(\`<!--for--><!--]-->\`)
}"
`)
})
Expand All @@ -33,7 +33,7 @@ describe('transition-group', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<div></div>\`)
})
_push(\`</ul>\`)
_push(\`<!--for--></ul>\`)
}"
`)
})
Expand All @@ -52,8 +52,10 @@ describe('transition-group', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<div></div>\`)
})
_push(\`<!--for-->\`)
if (false) {
_push(\`<div></div>\`)
_push(\`<!--if-->\`)
}
_push(\`</ul>\`)
}"
Expand All @@ -74,7 +76,7 @@ describe('transition-group', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<div></div>\`)
})
_push(\`</ul>\`)
_push(\`<!--for--></ul>\`)
}"
`)
})
Expand All @@ -96,7 +98,7 @@ describe('transition-group', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<div></div>\`)
})
_push(\`</\${_ctx.someTag}>\`)
_push(\`<!--for--></\${_ctx.someTag}>\`)
}"
`)
})
Expand All @@ -118,11 +120,14 @@ describe('transition-group', () => {
_ssrRenderList(10, (i) => {
_push(\`<div></div>\`)
})
_push(\`<!--for-->\`)
_ssrRenderList(10, (i) => {
_push(\`<div></div>\`)
})
_push(\`<!--for-->\`)
if (_ctx.ok) {
_push(\`<div>ok</div>\`)
_push(\`<!--if-->\`)
}
_push(\`<!--]-->\`)
}"
Expand Down
16 changes: 8 additions & 8 deletions packages/compiler-ssr/__tests__/ssrVFor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('ssr: v-for', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<div></div>\`)
})
_push(\`<!--]-->\`)
_push(\`<!--]--><!--for-->\`)
}"
`)
})
Expand All @@ -25,7 +25,7 @@ describe('ssr: v-for', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<div>foo<span>bar</span></div>\`)
})
_push(\`<!--]-->\`)
_push(\`<!--]--><!--for-->\`)
}"
`)
})
Expand All @@ -51,9 +51,9 @@ describe('ssr: v-for', () => {
_ssrInterpolate(j)
}</div>\`)
})
_push(\`<!--]--></div>\`)
_push(\`<!--]--><!--for--></div>\`)
})
_push(\`<!--]-->\`)
_push(\`<!--]--><!--for-->\`)
}"
`)
})
Expand All @@ -68,7 +68,7 @@ describe('ssr: v-for', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<!--[-->\${_ssrInterpolate(i)}<!--]-->\`)
})
_push(\`<!--]-->\`)
_push(\`<!--]--><!--for-->\`)
}"
`)
})
Expand All @@ -85,7 +85,7 @@ describe('ssr: v-for', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`<span>\${_ssrInterpolate(i)}</span>\`)
})
_push(\`<!--]-->\`)
_push(\`<!--]--><!--for-->\`)
}"
`)
})
Expand All @@ -107,7 +107,7 @@ describe('ssr: v-for', () => {
_ssrInterpolate(i + 1)
}</span><!--]-->\`)
})
_push(\`<!--]-->\`)
_push(\`<!--]--><!--for-->\`)
}"
`)
})
Expand All @@ -127,7 +127,7 @@ describe('ssr: v-for', () => {
_ssrRenderList(_ctx.list, ({ foo }, index) => {
_push(\`<div>\${_ssrInterpolate(foo + _ctx.bar + index)}</div>\`)
})
_push(\`<!--]-->\`)
_push(\`<!--]--><!--for-->\`)
}"
`)
})
Expand Down
Loading
Loading