]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): skip patching reserved props for custom elements (#14275)
authorDaniel Roe <daniel@roe.dev>
Mon, 19 Jan 2026 00:52:43 +0000 (00:52 +0000)
committerGitHub <noreply@github.com>
Mon, 19 Jan 2026 00:52:43 +0000 (08:52 +0800)
close #14274

packages/runtime-core/__tests__/hydration.spec.ts
packages/runtime-core/src/hydration.ts

index dffa2bc2246f44462a8c734b0d438681b08b0922..7017c0414f43db08ed7f317d8a1c19366d227130 100644 (file)
@@ -1597,6 +1597,24 @@ describe('SSR hydration', () => {
     expect((container.firstChild as any).foo).toBe(msg.value)
   })
 
+  // #14274
+  test('should not render ref on custom element during hydration', () => {
+    const container = document.createElement('div')
+    container.innerHTML = '<my-element>hello</my-element>'
+    const root = ref()
+    const app = createSSRApp({
+      render: () =>
+        h('my-element', {
+          ref: root,
+          innerHTML: 'hello',
+        }),
+    })
+    app.mount(container)
+    expect(container.innerHTML).toBe('<my-element>hello</my-element>')
+    expect((container.firstChild as Element).hasAttribute('ref')).toBe(false)
+    expect(root.value).toBe(container.firstChild)
+  })
+
   // #5728
   test('empty text node in slot', () => {
     const Comp = {
index a9ce641321fdb5d5d8d29fe5f1be6a23c6e691a7..a687d28d38070fcdafa324f0121f23c7cbd334e2 100644 (file)
@@ -507,7 +507,7 @@ export function createHydrationFunctions(
               (isOn(key) && !isReservedProp(key)) ||
               // force hydrate v-bind with .prop modifiers
               key[0] === '.' ||
-              isCustomElement
+              (isCustomElement && !isReservedProp(key))
             ) {
               patchProp(el, key, null, props[key], undefined, parentComponent)
             }