Skip to content

Transition is erroneously run when placed with bizarre sequence of sibling elements.  #9234

Open
@AnalyzePlatypus

Description

@AnalyzePlatypus

Version

2.5.21

Reproduction link

https://jsfiddle.net/analyzeplatypus/eywraw8t/513878/

screen recording 2018-12-20 at 8 21 07 pm mov

Steps to reproduce

The fiddle contains a seemingly random sequence of elements that illustrates the issue (described below).

  1. Open the JSFiddle
  2. Click the "Change" button
  3. The transition plays (it should not).

Try removing any of the DOM elements and the errant transition no longer plays!

What is expected?

The transition should not run.
(CSS transition classes should not be applied, hooks should not be called, etc.)

What is actually happening?

The transition is run (CSS transition classes are applied).


I came across this while building a complex form with multiple buttons that appear/disappear based on form state.
I noticed duplicated buttons in one of my unit tests, and found that a transition was being run even though its child's v-if binding was not being changed. I duplicated the component and whittled it down until I arrived at the attached JSFiddle.

This issue appears when the following sequence of elements are aligned:

  1. A boolean entry in the Vue component's data dictionary (hasChanges: false, in the JSFiddle)

The DOM contains
2. A <div> whose v-if is bound to the boolean entry (1).
2. A <transition> containing a button which modifies the boolean entry (1).
3. An empty <transition> element.
4. A <div> whose v-if is bound to the boolean entry (1) modified by logical NOT (!). (In the fiddle, v-if="!hasChanges").

With this exact structure, modifying the boolean entry (1) will run the transition - even though the transition is not bound to the boolean at all!

If you remove any of the above elements, or even reorder them (!) the errant transition will not run (which is the correct behavior).

Why does the transition run when placed with this particular set of siblings in this particular order?

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