Skip to content

v-once throwing error before destroy a custom component #4288

Closed
@marcosmoura

Description

@marcosmoura

Version and OS:

  • Vue 2.1.0
  • Webpack
  • Google Chrome

Problem:

I have the following HTML:

<md-select v-model="docs">
  <md-option v-for="doc in availableDocs" :value="doc" v-once>{{ doc }}</md-option>
</md-select>

If I use the v-once directive in the <md-option> the console throws an error. I'm using vue-router so when I try to change the url the following error occours:

Looking at the Vue source code (on the DevTools), I've found that the problem is occuring in the following function:

function destroy$1 (vnode) {
  if (!vnode.child._isDestroyed) {
    if (!vnode.data.keepAlive) {
      vnode.child.$destroy();
    } else {
      vnode.child._inactive = true;
      callHook(vnode.child, 'deactivated');
    }
  }
}

The .child property is undefined in this case and is throwing this error.

Tests

  • Some static <md-option> (without the v-for) - The same happens
  • With a HTML tag like span - Worked with and without the v-once

If I remove the v-once from the code the problem stops.

This is a bug?

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