Skip to content

When v-show render instruction is passed a reference object, the instruction will not work #10903

Open
@SamirGuo

Description

@SamirGuo

Version

2.6.10

Reproduction link

https://codepen.io/SamirGuo/pen/vYBezXz

Steps to reproduce

<div id="app">
<template>
  <div>
    <button @click="visible = !visible">显示/隐藏</button>
    <my-component :visible="visible" style="border-bottom: solid 1px #ccc" />
  </div>
</template>
</div>
const directive = {
    name: 'show',
    value: true
};

Vue.component('MyComponent', {
    props: {
        mystyle: '',
        visible: true
    },
    render(h) {
        directive.value = this.visible;
        return h('div', {
            // do not work!
            directives: [directive],
            // work well!
            // directives: [{
            //     name: 'show',
            //     value: this.visible
            // }],
            domProps: {
                innerText: 'sssssss'
            },
            style: this.mystyle
        });
    }
});


var Main = {
    data() {
      return { 
        visible: true
      };
    }
  };
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')

What is expected?

v-show to be applied

What is actually happening?

v-show isn't applied


When the instruction update logic assigns oldValue, oldVnode.data.directives ["show"] and vnode.data.directives ["show"] are actually the same object.
So dir.oldValue = oldDir.value is actually equivalent to dir.oldValue = dir.value; in the later update event, dir.oldValue === dir.value

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions