Skip to content

Commit d2df58e

Browse files
committed
move v-show marker to runtime so that render functions work as expected (fix #3488)
1 parent 16ce0f1 commit d2df58e

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

flow/vnode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ declare interface VNodeData {
3838
staticClass?: string;
3939
class?: any;
4040
style?: Array<Object> | Object;
41-
show?: true;
4241
props?: { [key: string]: any };
4342
attrs?: { [key: string]: string };
4443
domProps?: { [key: string]: any };
4544
hook?: { [key: string]: Function };
4645
on?: ?{ [key: string]: Function | Array<Function> };
4746
nativeOn?: { [key: string]: Function | Array<Function> };
4847
transition?: Object;
49-
transitionInjected?: boolean;
48+
transitionInjected?: boolean; // marker for transition insert hook injection
49+
show?: boolean; // marker for v-show
5050
inlineTemplate?: {
5151
render: Function;
5252
staticRenderFns: Array<Function>;

src/compiler/codegen/index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ function genData (el: ASTElement): string | void {
130130
for (let i = 0; i < dataGenFns.length; i++) {
131131
data += dataGenFns[i](el)
132132
}
133-
// v-show, used to avoid transition being applied
134-
// since v-show takes it over
135-
if (el.attrsMap['v-show']) {
136-
data += 'show:true,'
137-
}
138133
// attributes
139134
if (el.attrs) {
140135
data += `attrs:{${genProps(el.attrs)}},`

src/platforms/web/runtime/components/transition.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ export default {
126126
const oldRawChild = this._vnode
127127
const oldChild: any = getRealChild(oldRawChild)
128128

129+
// mark v-show
130+
// so that the transition module can hand over the control to the directive
131+
if (child.data.directives && child.data.directives.some(d => d.name === 'show')) {
132+
child.data.show = true
133+
}
134+
129135
if (oldChild && oldChild.data && oldChild.key !== child.key) {
130136
// replace old child transition data with fresh one
131137
// important for dynamic transitions!

test/unit/modules/compiler/codegen.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('codegen', () => {
148148
it('generate v-show directive', () => {
149149
assertCodegen(
150150
'<p v-show="shown">hello world</p>',
151-
`with(this){return _h('p',{directives:[{name:"show",value:(shown),expression:"shown"}],show:true},["hello world"])}`
151+
`with(this){return _h('p',{directives:[{name:"show",value:(shown),expression:"shown"}]},["hello world"])}`
152152
)
153153
})
154154

0 commit comments

Comments
 (0)