|
12 | 12 | // nodes will remain where they should be.
|
13 | 13 |
|
14 | 14 | import { warn, extend } from 'core/util/index'
|
| 15 | +import { addClass, removeClass } from '../class-util' |
15 | 16 | import { transitionProps, extractTransitionData } from './transition'
|
| 17 | + |
16 | 18 | import {
|
17 | 19 | hasTransition,
|
18 |
| - addTransitionClass, |
19 |
| - removeTransitionClass, |
20 | 20 | getTransitionInfo,
|
21 |
| - transitionEndEvent |
| 21 | + transitionEndEvent, |
| 22 | + addTransitionClass, |
| 23 | + removeTransitionClass |
22 | 24 | } from '../transition-util'
|
23 | 25 |
|
24 | 26 | const props = extend({
|
@@ -122,17 +124,28 @@ export default {
|
122 | 124 | },
|
123 | 125 |
|
124 | 126 | methods: {
|
125 |
| - hasMove (el: Element, moveClass: string): boolean { |
| 127 | + hasMove (el: any, moveClass: string): boolean { |
126 | 128 | /* istanbul ignore if */
|
127 | 129 | if (!hasTransition) {
|
128 | 130 | return false
|
129 | 131 | }
|
130 | 132 | if (this._hasMove != null) {
|
131 | 133 | return this._hasMove
|
132 | 134 | }
|
133 |
| - addTransitionClass(el, moveClass) |
134 |
| - const info = getTransitionInfo(el) |
135 |
| - removeTransitionClass(el, moveClass) |
| 135 | + // Detect whether an element with the move class applied has |
| 136 | + // CSS transitions. Since the element may be inside an entering |
| 137 | + // transition at this very moment, we make a clone of it and remove |
| 138 | + // all other transition classes applied to ensure only the move class |
| 139 | + // is applied. |
| 140 | + const clone = el.cloneNode() |
| 141 | + if (el._transitionClasses) { |
| 142 | + el._transitionClasses.forEach(cls => { removeClass(clone, cls) }) |
| 143 | + } |
| 144 | + addClass(clone, moveClass) |
| 145 | + clone.style.display = 'none' |
| 146 | + this.$el.appendChild(clone) |
| 147 | + const info = getTransitionInfo(clone) |
| 148 | + this.$el.removeChild(clone) |
136 | 149 | return (this._hasMove = info.hasTransform)
|
137 | 150 | }
|
138 | 151 | }
|
|
0 commit comments