mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-02 12:07:39 +08:00
move v-show marker to runtime so that render functions work as expected (fix #3488)
This commit is contained in:
parent
16ce0f13d5
commit
d2df58e547
@ -38,7 +38,6 @@ declare interface VNodeData {
|
||||
staticClass?: string;
|
||||
class?: any;
|
||||
style?: Array<Object> | Object;
|
||||
show?: true;
|
||||
props?: { [key: string]: any };
|
||||
attrs?: { [key: string]: string };
|
||||
domProps?: { [key: string]: any };
|
||||
@ -46,7 +45,8 @@ declare interface VNodeData {
|
||||
on?: ?{ [key: string]: Function | Array<Function> };
|
||||
nativeOn?: { [key: string]: Function | Array<Function> };
|
||||
transition?: Object;
|
||||
transitionInjected?: boolean;
|
||||
transitionInjected?: boolean; // marker for transition insert hook injection
|
||||
show?: boolean; // marker for v-show
|
||||
inlineTemplate?: {
|
||||
render: Function;
|
||||
staticRenderFns: Array<Function>;
|
||||
|
@ -130,11 +130,6 @@ function genData (el: ASTElement): string | void {
|
||||
for (let i = 0; i < dataGenFns.length; i++) {
|
||||
data += dataGenFns[i](el)
|
||||
}
|
||||
// v-show, used to avoid transition being applied
|
||||
// since v-show takes it over
|
||||
if (el.attrsMap['v-show']) {
|
||||
data += 'show:true,'
|
||||
}
|
||||
// attributes
|
||||
if (el.attrs) {
|
||||
data += `attrs:{${genProps(el.attrs)}},`
|
||||
|
@ -126,6 +126,12 @@ export default {
|
||||
const oldRawChild = this._vnode
|
||||
const oldChild: any = getRealChild(oldRawChild)
|
||||
|
||||
// mark v-show
|
||||
// so that the transition module can hand over the control to the directive
|
||||
if (child.data.directives && child.data.directives.some(d => d.name === 'show')) {
|
||||
child.data.show = true
|
||||
}
|
||||
|
||||
if (oldChild && oldChild.data && oldChild.key !== child.key) {
|
||||
// replace old child transition data with fresh one
|
||||
// important for dynamic transitions!
|
||||
|
@ -148,7 +148,7 @@ describe('codegen', () => {
|
||||
it('generate v-show directive', () => {
|
||||
assertCodegen(
|
||||
'<p v-show="shown">hello world</p>',
|
||||
`with(this){return _h('p',{directives:[{name:"show",value:(shown),expression:"shown"}],show:true},["hello world"])}`
|
||||
`with(this){return _h('p',{directives:[{name:"show",value:(shown),expression:"shown"}]},["hello world"])}`
|
||||
)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user