2020-01-29 07:48:27 +08:00
|
|
|
// TODO explain why we are no longer checking boolean/enumerated here
|
|
|
|
|
|
|
|
export function patchAttr(
|
|
|
|
el: Element,
|
|
|
|
key: string,
|
|
|
|
value: any,
|
|
|
|
isSVG: boolean
|
|
|
|
) {
|
|
|
|
if (isSVG && key.indexOf('xlink:') === 0) {
|
|
|
|
// TODO handle xlink
|
|
|
|
} else if (value == null) {
|
2019-10-13 07:25:04 +08:00
|
|
|
el.removeAttribute(key)
|
2018-09-19 23:35:38 +08:00
|
|
|
} else {
|
2020-01-29 07:48:27 +08:00
|
|
|
// TODO in dev mode, warn against incorrect values for boolean or
|
|
|
|
// enumerated attributes
|
2019-10-13 07:25:04 +08:00
|
|
|
el.setAttribute(key, value)
|
2018-09-19 23:35:38 +08:00
|
|
|
}
|
|
|
|
}
|