mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-04 21:17:55 +08:00
feat: support v-html for SVG elements (#8652)
This commit is contained in:
parent
22ad266151
commit
a981c80d2a
@ -1,6 +1,9 @@
|
||||
/* @flow */
|
||||
|
||||
import { isDef, isUndef, extend, toNumber } from 'shared/util'
|
||||
import { isSVG } from 'web/util/index'
|
||||
|
||||
let svgContainer
|
||||
|
||||
function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
|
||||
@ -55,6 +58,17 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
if (shouldUpdateValue(elm, strCur)) {
|
||||
elm.value = strCur
|
||||
}
|
||||
} else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
|
||||
// IE doesn't support innerHTML for SVG elements
|
||||
svgContainer = svgContainer || document.createElement('div')
|
||||
svgContainer.innerHTML = `<svg>${cur}</svg>`
|
||||
const svg = svgContainer.firstChild
|
||||
while (elm.firstChild) {
|
||||
elm.removeChild(elm.firstChild)
|
||||
}
|
||||
while (svg.firstChild) {
|
||||
elm.appendChild(svg.firstChild)
|
||||
}
|
||||
} else {
|
||||
elm[key] = cur
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user