Skip to content

Commit 172cb8b

Browse files
authored
fix(runtime-vapor): remove v-cloak and add data-v-app after app mount (#14035)
1 parent 0f4d7fb commit 172cb8b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createVaporApp, template } from '../../src'
2+
3+
describe('vCloak', () => {
4+
test('should be removed after mount', () => {
5+
const root = document.createElement('div')
6+
root.setAttribute('v-cloak', '')
7+
createVaporApp({
8+
setup() {
9+
expect(root.hasAttribute('v-cloak')).toBe(true)
10+
expect(root.hasAttribute('data-v-app')).toBe(false)
11+
return template(`<div></div>`)()
12+
},
13+
}).mount(root)
14+
expect(root.hasAttribute('v-cloak')).toBe(false)
15+
expect(root.hasAttribute('data-v-app')).toBe(true)
16+
})
17+
})

packages/runtime-vapor/src/apiCreateApp.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ function postPrepareApp(app: App) {
9494
const mount = app.mount
9595
app.mount = (container, ...args: any[]) => {
9696
container = normalizeContainer(container) as ParentNode
97-
return mount(container, ...args)
97+
const proxy = mount(container, ...args)
98+
if (container instanceof Element) {
99+
container.removeAttribute('v-cloak')
100+
container.setAttribute('data-v-app', '')
101+
}
102+
return proxy
98103
}
99104
}
100105

0 commit comments

Comments
 (0)