don't call rm() twice if transition finishes before frame callback

pull/1030/head
Tom Jenkinson 3 years ago
parent b826e80012
commit 22927f22d6

@ -95,8 +95,12 @@ function applyRemoveStyle(vnode: VNode, rm: () => void): void {
} }
let running = 0; let running = 0;
let started = false;
const onRun = function (ev: TransitionEvent) { const onRun = function (ev: TransitionEvent) {
if (ev.target === elm) running++; if (ev.target === elm) {
started = true;
running++;
}
}; };
const onEnd = function (ev: TransitionEvent) { const onEnd = function (ev: TransitionEvent) {
if (ev.target === elm && --running === 0) { if (ev.target === elm && --running === 0) {
@ -114,7 +118,7 @@ function applyRemoveStyle(vnode: VNode, rm: () => void): void {
(elm as Element).addEventListener("transitionend", onEnd); (elm as Element).addEventListener("transitionend", onEnd);
nextFrame(function () { nextFrame(function () {
if (running === 0) { if (!started) {
cleanUp(); cleanUp();
rm(); rm();
} }

Loading…
Cancel
Save