MCPcopy
hub / github.com/vuejs/core / hasCSSTransform

Function hasCSSTransform

packages/runtime-dom/src/components/TransitionGroup.ts:237–263  ·  view source on GitHub ↗
(
  el: ElementWithTransition,
  root: Node,
  moveClass: string,
)

Source from the content-addressed store, hash-verified

235}
236
237function hasCSSTransform(
238 el: ElementWithTransition,
239 root: Node,
240 moveClass: string,
241): boolean {
242 // Detect whether an element with the move class applied has
243 // CSS transitions. Since the element may be inside an entering
244 // transition at this very moment, we make a clone of it and remove
245 // all other transition classes applied to ensure only the move class
246 // is applied.
247 const clone = el.cloneNode() as HTMLElement
248 const _vtc = el[vtcKey]
249 if (_vtc) {
250 _vtc.forEach(cls => {
251 cls.split(/\s+/).forEach(c => c && clone.classList.remove(c))
252 })
253 }
254 moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c))
255 clone.style.display = 'none'
256 const container = (
257 root.nodeType === 1 ? root : root.parentNode
258 ) as HTMLElement
259 container.appendChild(clone)
260 const { hasTransform } = getTransitionInfo(clone)
261 container.removeChild(clone)
262 return hasTransform
263}

Callers 1

setupFunction · 0.85

Calls 4

getTransitionInfoFunction · 0.90
cloneNodeMethod · 0.80
forEachMethod · 0.80
removeMethod · 0.80

Tested by

no test coverage detected