Skip to content

Commit 0dac437

Browse files
committed
test: add test
1 parent 73bb298 commit 0dac437

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

packages/compiler-vapor/__tests__/transforms/__snapshots__/vShow.spec.ts.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3+
exports[`compiler: v-show transform > on component 1`] = `
4+
"import { resolveComponent as _resolveComponent, createComponentWithFallback as _createComponentWithFallback, applyVShow as _applyVShow } from 'vue';
5+
6+
export function render(_ctx) {
7+
const _component_Comp = _resolveComponent("Comp")
8+
const n0 = _createComponentWithFallback(_component_Comp, null, null, true)
9+
_applyVShow(n0, () => (_ctx.foo))
10+
return n0
11+
}"
12+
`;
13+
314
exports[`compiler: v-show transform > simple expression 1`] = `
415
"import { applyVShow as _applyVShow, template as _template } from 'vue';
516
const t0 = _template("<div></div>", true)

packages/compiler-vapor/__tests__/transforms/vShow.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ describe('compiler: v-show transform', () => {
2626
}),
2727
)
2828
})
29+
30+
test('on component', () => {
31+
const { code } = compileWithVShow(`<Comp v-show="foo"/>`)
32+
expect(code).toMatchSnapshot()
33+
})
2934
})

packages/compiler-vapor/src/transforms/transformElement.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ function transformComponentElement(
136136
once: context.inVOnce,
137137
dynamic: dynamicComponent,
138138
}
139+
140+
// ensure v-show is handled after the component is created
139141
const hasVShow = findDir(node, 'show')
140142
if (hasVShow) {
141143
const showOperationIndex = context.block.operation.findIndex(

0 commit comments

Comments
 (0)