We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
effect
1 parent 5a279be commit d536488Copy full SHA for d536488
packages/runtime-dom/src/directives/vShow.ts
@@ -1,4 +1,5 @@
1
-import { ObjectDirective } from '@vue/runtime-core'
+import { ObjectDirective, type VNode } from '@vue/runtime-core'
2
+import { ShapeFlags } from '@vue/shared'
3
4
export const vShowOldKey = Symbol('_vod')
5
@@ -43,6 +44,16 @@ export const vShow: ObjectDirective<VShowElement> = {
43
44
}
45
46
function setDisplay(el: VShowElement, value: unknown): void {
47
+ // @ts-expect-error
48
+ const vnode = el.__vnode as VNode
49
+ if (vnode && vnode.shapeFlag & ShapeFlags.COMPONENT) {
50
+ const effect = vnode.ctx!.effect
51
+ if (value) {
52
+ effect.resume(true)
53
+ } else {
54
+ effect.pause()
55
+ }
56
57
el.style.display = value ? el[vShowOldKey] : 'none'
58
59
0 commit comments