Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,17 @@ export function render(_ctx) {
`;

exports[`compile > expression parsing > v-slot 1`] = `
"import { resolveComponent as _resolveComponent, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, withVaporCtx as _withVaporCtx, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
"import { resolveComponent as _resolveComponent, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
const t0 = _template(" ")

export function render(_ctx) {
const _component_Comp = _resolveComponent("Comp")
const n1 = _createComponentWithFallback(_component_Comp, null, {
"foo": _withVaporCtx((_slotProps0) => {
"foo": (_slotProps0) => {
const n0 = t0()
_renderEffect(() => _setText(n0, _toDisplayString(_slotProps0.a + _slotProps0.b)))
return n0
})
}
}, true)
return n1
}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`scopeId compiler support > should wrap default slot 1`] = `
"import { resolveComponent as _resolveComponent, withVaporCtx as _withVaporCtx, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
"import { resolveComponent as _resolveComponent, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
const t0 = _template("<div></div>")

export function render(_ctx) {
const _component_Child = _resolveComponent("Child")
const n1 = _createComponentWithFallback(_component_Child, null, {
"default": _withVaporCtx(() => {
"default": () => {
const n0 = t0()
return n0
})
}
}, true)
return n1
}"
`;

exports[`scopeId compiler support > should wrap dynamic slots 1`] = `
"import { resolveComponent as _resolveComponent, withVaporCtx as _withVaporCtx, createForSlots as _createForSlots, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
"import { resolveComponent as _resolveComponent, createForSlots as _createForSlots, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
const t0 = _template("<div test></div>")

export function render(_ctx) {
Expand All @@ -27,18 +27,18 @@ export function render(_ctx) {
() => (_ctx.ok
? {
name: "foo",
fn: _withVaporCtx(() => {
fn: () => {
const n0 = t0()
return n0
})
}
}
: void 0),
() => (_createForSlots(_ctx.list, (i) => ({
name: i,
fn: _withVaporCtx(() => {
fn: () => {
const n2 = t0()
return n2
})
}
})))
]
}, true)
Expand All @@ -47,22 +47,22 @@ export function render(_ctx) {
`;

exports[`scopeId compiler support > should wrap named slots 1`] = `
"import { resolveComponent as _resolveComponent, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, withVaporCtx as _withVaporCtx, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
"import { resolveComponent as _resolveComponent, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createComponentWithFallback as _createComponentWithFallback, template as _template } from 'vue';
const t0 = _template(" ")
const t1 = _template("<div test></div>")

export function render(_ctx) {
const _component_Child = _resolveComponent("Child")
const n4 = _createComponentWithFallback(_component_Child, null, {
"foo": _withVaporCtx((_slotProps0) => {
"foo": (_slotProps0) => {
const n0 = t0()
_renderEffect(() => _setText(n0, _toDisplayString(_slotProps0.msg)))
return n0
}),
"bar": _withVaporCtx(() => {
},
"bar": () => {
const n2 = t1()
return n2
})
}
}, true)
return n4
}"
Expand Down
10 changes: 5 additions & 5 deletions packages/compiler-vapor/__tests__/scopeId.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function compile(template: string | RootNode, options: CompilerOptions = {}) {
describe('scopeId compiler support', () => {
test('should wrap default slot', () => {
const code = compile(`<Child><div/></Child>`)
expect(code).toMatch(`"default": _withVaporCtx(() => {`)
expect(code).toMatch(`"default": () => {`)
expect(code).toMatchSnapshot()
})

Expand All @@ -34,8 +34,8 @@ describe('scopeId compiler support', () => {
scopeId: 'test',
},
)
expect(code).toMatch(`"foo": _withVaporCtx((_slotProps0) => {`)
expect(code).toMatch(`"bar": _withVaporCtx(() => {`)
expect(code).toMatch(`"foo": (_slotProps0) => {`)
expect(code).toMatch(`"bar": () => {`)
expect(code).toMatchSnapshot()
})

Expand All @@ -51,8 +51,8 @@ describe('scopeId compiler support', () => {
scopeId: 'test',
},
)
expect(code).toMatch(/name: "foo",\s+fn: _withVaporCtx\(/)
expect(code).toMatch(/name: i,\s+fn: _withVaporCtx\(/)
expect(code).toMatch(/name: "foo",\s+fn: \(/)
expect(code).toMatch(/name: i,\s+fn: \(/)
expect(code).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`compiler: transition > basic 1`] = `
"import { VaporTransition as _VaporTransition, applyVShow as _applyVShow, withVaporCtx as _withVaporCtx, createComponent as _createComponent, template as _template } from 'vue';
"import { VaporTransition as _VaporTransition, applyVShow as _applyVShow, createComponent as _createComponent, template as _template } from 'vue';
const t0 = _template("<h1>foo</h1>")

export function render(_ctx) {
const n1 = _createComponent(_VaporTransition, { persisted: () => ("") }, {
"default": _withVaporCtx(() => {
"default": () => {
const n0 = t0()
_applyVShow(n0, () => (_ctx.show))
return n0
})
}
}, true)
return n1
}"
`;

exports[`compiler: transition > inject persisted when child has v-show 1`] = `
"import { VaporTransition as _VaporTransition, applyVShow as _applyVShow, withVaporCtx as _withVaporCtx, createComponent as _createComponent, template as _template } from 'vue';
"import { VaporTransition as _VaporTransition, applyVShow as _applyVShow, createComponent as _createComponent, template as _template } from 'vue';
const t0 = _template("<div></div>")

export function render(_ctx) {
const n1 = _createComponent(_VaporTransition, { persisted: () => ("") }, {
"default": _withVaporCtx(() => {
"default": () => {
const n0 = t0()
_applyVShow(n0, () => (_ctx.ok))
return n0
})
}
}, true)
return n1
}"
`;

exports[`compiler: transition > the v-if/else-if/else branches in Transition should ignore comments 1`] = `
"import { VaporTransition as _VaporTransition, setInsertionState as _setInsertionState, createIf as _createIf, withVaporCtx as _withVaporCtx, createComponent as _createComponent, template as _template } from 'vue';
"import { VaporTransition as _VaporTransition, setInsertionState as _setInsertionState, createIf as _createIf, createComponent as _createComponent, template as _template } from 'vue';
const t0 = _template("<div>hey</div>")
const t1 = _template("<p></p>")
const t2 = _template("<div></div>")

export function render(_ctx) {
const n16 = _createComponent(_VaporTransition, null, {
"default": _withVaporCtx(() => {
"default": () => {
const n0 = _createIf(() => (_ctx.a), () => {
const n2 = t0()
n2.$key = 2
Expand All @@ -63,14 +63,14 @@ export function render(_ctx) {
return n14
}))
return [n0, n3, n7]
})
}
}, true)
return n16
}"
`;

exports[`compiler: transition > v-show + appear 1`] = `
"import { VaporTransition as _VaporTransition, applyVShow as _applyVShow, withVaporCtx as _withVaporCtx, createComponent as _createComponent, template as _template } from 'vue';
"import { VaporTransition as _VaporTransition, applyVShow as _applyVShow, createComponent as _createComponent, template as _template } from 'vue';
const t0 = _template("<h1>foo</h1>")

export function render(_ctx) {
Expand All @@ -79,49 +79,49 @@ export function render(_ctx) {
appear: () => (""),
persisted: () => ("")
}, {
"default": _withVaporCtx(() => {
"default": () => {
const n0 = t0()
deferredApplyVShows.push(() => _applyVShow(n0, () => (_ctx.show)))
return n0
})
}
}, true)
deferredApplyVShows.forEach(fn => fn())
return n1
}"
`;

exports[`compiler: transition > work with dynamic keyed children 1`] = `
"import { VaporTransition as _VaporTransition, createKeyedFragment as _createKeyedFragment, withVaporCtx as _withVaporCtx, createComponent as _createComponent, template as _template } from 'vue';
"import { VaporTransition as _VaporTransition, createKeyedFragment as _createKeyedFragment, createComponent as _createComponent, template as _template } from 'vue';
const t0 = _template("<h1>foo</h1>")

export function render(_ctx) {
const n1 = _createComponent(_VaporTransition, null, {
"default": _withVaporCtx(() => {
"default": () => {
return _createKeyedFragment(() => _ctx.key, () => {
const n0 = t0()
n0.$key = _ctx.key
return n0
})
})
}
}, true)
return n1
}"
`;

exports[`compiler: transition > work with v-if 1`] = `
"import { VaporTransition as _VaporTransition, createIf as _createIf, withVaporCtx as _withVaporCtx, createComponent as _createComponent, template as _template } from 'vue';
"import { VaporTransition as _VaporTransition, createIf as _createIf, createComponent as _createComponent, template as _template } from 'vue';
const t0 = _template("<h1>foo</h1>")

export function render(_ctx) {
const n3 = _createComponent(_VaporTransition, null, {
"default": _withVaporCtx(() => {
"default": () => {
const n0 = _createIf(() => (_ctx.show), () => {
const n2 = t0()
n2.$key = 2
return n2
})
return n0
})
}
}, true)
return n3
}"
Expand Down
Loading
Loading