refactor(runtime-dom): remove xlink support since it's been deprecated
This commit is contained in:
parent
675ce2c15d
commit
a7eefaff1e
@ -1,31 +1,7 @@
|
|||||||
const xlinkNS = 'http://www.w3.org/1999/xlink'
|
export function patchAttr(el: Element, key: string, value: any) {
|
||||||
|
|
||||||
function isXlink(name: string): boolean {
|
|
||||||
return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
|
|
||||||
}
|
|
||||||
|
|
||||||
function getXlinkProp(name: string): string {
|
|
||||||
return isXlink(name) ? name.slice(6, name.length) : ''
|
|
||||||
}
|
|
||||||
|
|
||||||
export function patchAttr(
|
|
||||||
el: Element,
|
|
||||||
key: string,
|
|
||||||
value: any,
|
|
||||||
isSVG: boolean
|
|
||||||
) {
|
|
||||||
// isSVG short-circuits isXlink check
|
|
||||||
if (isSVG && isXlink(key)) {
|
|
||||||
if (value == null) {
|
|
||||||
el.removeAttributeNS(xlinkNS, getXlinkProp(key))
|
|
||||||
} else {
|
|
||||||
el.setAttributeNS(xlinkNS, key, value)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
el.removeAttribute(key)
|
el.removeAttribute(key)
|
||||||
} else {
|
} else {
|
||||||
el.setAttribute(key, value)
|
el.setAttribute(key, value)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ export function patchProp(
|
|||||||
unmountChildren
|
unmountChildren
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
patchAttr(el, key, nextValue, isSVG)
|
patchAttr(el, key, nextValue)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user