From: Gabriel Loiácono <32134586+loiacon@users.noreply.github.com> Date: Sat, 23 Nov 2019 05:02:39 +0000 (-0300) Subject: refactor(transition): avoid repeated code (#483) X-Git-Tag: v3.0.0-alpha.0~164 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f399b5476ffc5fd02d64155302adce78097d39c1;p=thirdparty%2Fvuejs%2Fcore.git refactor(transition): avoid repeated code (#483) --- diff --git a/packages/runtime-dom/src/components/CSSTransition.ts b/packages/runtime-dom/src/components/CSSTransition.ts index 082cc48a4b..58f9e71c20 100644 --- a/packages/runtime-dom/src/components/CSSTransition.ts +++ b/packages/runtime-dom/src/components/CSSTransition.ts @@ -251,13 +251,12 @@ function getTransitionInfo( ): CSSTransitionInfo { const styles: any = window.getComputedStyle(el) // JSDOM may return undefined for transition properties - const transitionDelays = (styles[TRANSITION + 'Delay'] || '').split(', ') - const transitionDurations = (styles[TRANSITION + 'Duration'] || '').split( - ', ' - ) + const getStyleProperties = (key: string) => (styles[key] || '').split(', ') + const transitionDelays = getStyleProperties(TRANSITION + 'Delay') + const transitionDurations = getStyleProperties(TRANSITION + 'Duration') const transitionTimeout = getTimeout(transitionDelays, transitionDurations) - const animationDelays = (styles[ANIMATION + 'Delay'] || '').split(', ') - const animationDurations = (styles[ANIMATION + 'Duration'] || '').split(', ') + const animationDelays = getStyleProperties(ANIMATION + 'Delay') + const animationDurations = getStyleProperties(ANIMATION + 'Duration') const animationTimeout = getTimeout(animationDelays, animationDurations) let type: CSSTransitionInfo['type'] = null @@ -301,12 +300,7 @@ function getTimeout(delays: string[], durations: string[]): number { while (delays.length < durations.length) { delays = delays.concat(delays) } - return Math.max.apply( - null, - durations.map((d, i) => { - return toMs(d) + toMs(delays[i]) - }) - ) + return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i]))) } // Old versions of Chromium (below 61.0.3163.100) formats floating pointer