Skip to content

Commit

Permalink
fixed: ie issues on svg tags and closes #2464
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Nov 5, 2017
1 parent 04d7c8a commit 6ab449b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/browser/common/util/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export function isSvg(el) {
/**
* Create a generic DOM node
* @param { String } name - name of the DOM node we want to create
* @param { Boolean } isSvg - true if we need to use an svg node
* @returns { Object } DOM node just created
*/
export function mkEl(name) {
Expand All @@ -61,15 +60,18 @@ export function mkEl(name) {
* Set the inner html of any DOM node SVGs included
* @param { Object } container - DOM node where we'll inject new html
* @param { String } html - html to inject
* @param { Boolean } isSvg - svg tags should be treated a bit differently
*/
/* istanbul ignore next */
export function setInnerHTML(container, html) {
export function setInnerHTML(container, html, isSvg) {
if (!isUndefined(container.innerHTML))
container.innerHTML = html
// some browsers do not support innerHTML on the SVGs tags
else {
const doc = new DOMParser().parseFromString(html, 'application/xml')
const markup = isSvg ? `<svg xmlns="${ SVG_NS }">${ html }</svg>` : html
const doc = new DOMParser().parseFromString(markup, 'application/xml')
const node = container.ownerDocument.importNode(doc.documentElement, true)

container.appendChild(node)
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/tag/mkdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function mkdom(tmpl, html, isSvg) {
if (tblTags.test(tagName))
el = specialTags(el, tmpl, tagName)
else
setInnerHTML(el, tmpl)
setInnerHTML(el, tmpl, isSvg)

return el
}

0 comments on commit 6ab449b

Please sign in to comment.