( el: Element, key: string, value: any, isSVG: boolean, instance?: ComponentInternalInstance | null, isBoolean: boolean = isSpecialBooleanAttr(key), )
| 14 | export const xlinkNS = 'http://www.w3.org/1999/xlink' |
| 15 | |
| 16 | export function patchAttr( |
| 17 | el: Element, |
| 18 | key: string, |
| 19 | value: any, |
| 20 | isSVG: boolean, |
| 21 | instance?: ComponentInternalInstance | null, |
| 22 | isBoolean: boolean = isSpecialBooleanAttr(key), |
| 23 | ): void { |
| 24 | if (isSVG && key.startsWith('xlink:')) { |
| 25 | if (value == null) { |
| 26 | el.removeAttributeNS(xlinkNS, key.slice(6, key.length)) |
| 27 | } else { |
| 28 | el.setAttributeNS(xlinkNS, key, value) |
| 29 | } |
| 30 | } else { |
| 31 | if (__COMPAT__ && compatCoerceAttr(el, key, value, instance)) { |
| 32 | return |
| 33 | } |
| 34 | |
| 35 | // note we are only checking boolean attributes that don't have a |
| 36 | // corresponding dom prop of the same name here. |
| 37 | if (value == null || (isBoolean && !includeBooleanAttr(value))) { |
| 38 | el.removeAttribute(key) |
| 39 | } else { |
| 40 | // attribute value is a string https://html.spec.whatwg.org/multipage/dom.html#attributes |
| 41 | el.setAttribute( |
| 42 | key, |
| 43 | isBoolean ? '' : isSymbol(value) ? String(value) : value, |
| 44 | ) |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // 2.x compat |
| 50 | const isEnumeratedAttr = __COMPAT__ |
no test coverage detected