Skip to content

v-if throws an error if toggled off after the element has been removed from the DOM through other means #14099

@araney

Description

@araney

Version

3.5.24

Reproduction link

play.vuejs.org/

Steps to reproduce

  • click "Remove Target" to remove the target element (which has a v-if directive on it)
  • toggle "Show Target" to trigger the v-if directive's hide behavior
  • note the error that is thrown "Cannot read properties of null (reading 'insertBefore')"

What is expected?

Toggling a v-if for an unbound element should be a no-op. Nothing should change.

What is actually happening?

An uncaught error is being thrown, which can break other parts of a complex application.


This bug was encountered when interacting with other custom directives. A local change to Vue to include a null check against the "parent" in "nodeOps.insert" within "runtime-dom.esm-bundler.js" resolves the issue.

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