]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-vapor): remove v-cloak and add data-v-app after app mount (#14035)
authoredison <daiwei521@126.com>
Wed, 5 Nov 2025 03:55:27 +0000 (11:55 +0800)
committerGitHub <noreply@github.com>
Wed, 5 Nov 2025 03:55:27 +0000 (11:55 +0800)
packages/runtime-vapor/__tests__/directives/vCloak.spec.ts [new file with mode: 0644]
packages/runtime-vapor/src/apiCreateApp.ts

diff --git a/packages/runtime-vapor/__tests__/directives/vCloak.spec.ts b/packages/runtime-vapor/__tests__/directives/vCloak.spec.ts
new file mode 100644 (file)
index 0000000..e69c5ea
--- /dev/null
@@ -0,0 +1,17 @@
+import { createVaporApp, template } from '../../src'
+
+describe('vCloak', () => {
+  test('should be removed after mount', () => {
+    const root = document.createElement('div')
+    root.setAttribute('v-cloak', '')
+    createVaporApp({
+      setup() {
+        expect(root.hasAttribute('v-cloak')).toBe(true)
+        expect(root.hasAttribute('data-v-app')).toBe(false)
+        return template(`<div></div>`)()
+      },
+    }).mount(root)
+    expect(root.hasAttribute('v-cloak')).toBe(false)
+    expect(root.hasAttribute('data-v-app')).toBe(true)
+  })
+})
index 89fc6179ee04a96ce20d1f5dae172ea7b4d1a341..37e77e8831ec9f51168772ba4a7ef71bfd76abcf 100644 (file)
@@ -94,7 +94,12 @@ function postPrepareApp(app: App) {
   const mount = app.mount
   app.mount = (container, ...args: any[]) => {
     container = normalizeContainer(container) as ParentNode
-    return mount(container, ...args)
+    const proxy = mount(container, ...args)
+    if (container instanceof Element) {
+      container.removeAttribute('v-cloak')
+      container.setAttribute('data-v-app', '')
+    }
+    return proxy
   }
 }