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

Function patchClass

packages/runtime-dom/src/modules/class.ts:5–26  ·  view source on GitHub ↗
(
  el: Element,
  value: string | null,
  isSVG: boolean,
)

Source from the content-addressed store, hash-verified

3// compiler should normalize class + :class bindings on the same element
4// into a single binding ['staticClass', dynamic]
5export function patchClass(
6 el: Element,
7 value: string | null,
8 isSVG: boolean,
9): void {
10 // directly setting className should be faster than setAttribute in theory
11 // if this is an element during a transition, take the temporary transition
12 // classes into account.
13 const transitionClasses = (el as ElementWithTransition)[vtcKey]
14 if (transitionClasses) {
15 value = (
16 value ? [value, ...transitionClasses] : [...transitionClasses]
17 ).join(' ')
18 }
19 if (value == null) {
20 el.removeAttribute('class')
21 } else if (isSVG) {
22 el.setAttribute('class', value)
23 } else {
24 el.className = value
25 }
26}

Callers 1

patchPropFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected