fix(runtime-dom): support mounting app to svg container (#2929)
fix #2926
This commit is contained in:
15
packages/runtime-dom/__tests__/createApp.spec.ts
Normal file
15
packages/runtime-dom/__tests__/createApp.spec.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { createApp, h } from '../src'
|
||||
|
||||
describe('createApp for dom', () => {
|
||||
// #2926
|
||||
test('mount to SVG container', () => {
|
||||
const root = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
|
||||
createApp({
|
||||
render() {
|
||||
return h('g')
|
||||
}
|
||||
}).mount(root)
|
||||
expect(root.children.length).toBe(1)
|
||||
expect(root.children[0] instanceof SVGElement).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -69,7 +69,7 @@ export const createApp = ((...args) => {
|
||||
}
|
||||
// clear content before mounting
|
||||
container.innerHTML = ''
|
||||
const proxy = mount(container)
|
||||
const proxy = mount(container, false, container instanceof SVGElement)
|
||||
if (container instanceof Element) {
|
||||
container.removeAttribute('v-cloak')
|
||||
container.setAttribute('data-v-app', '')
|
||||
@@ -92,7 +92,7 @@ export const createSSRApp = ((...args) => {
|
||||
app.mount = (containerOrSelector: Element | ShadowRoot | string): any => {
|
||||
const container = normalizeContainer(containerOrSelector)
|
||||
if (container) {
|
||||
return mount(container, true)
|
||||
return mount(container, true, container instanceof SVGElement)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user