Skip to content

Slot + v-if="false" + @click = wrong bindings #2348

@fnlctrl

Description

@fnlctrl

Came across this strange bug today.
html:

<foo>
  <div slot="a" v-if="false"></div> 
  <!-- <div slot="a" v-if="true">No warnings if v-if="true"</div> -->
</foo>

js:

var vm = new Vue({
  el: 'body',
  components: {
    foo: {
      template: `
        <slot name="a">
          <div @click="bar"></div>
        </slot>
      `,
      methods: {
        bar() { /* do something */ }
      }
    }
  }
})

gives:

[Vue warn]: v-on:click="bar" expects a function value, got undefined.

Fiddle:
https://jsfiddle.net/fnlCtrl/ce1Lc0xs/

(Happy new year by the way :D)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions