Backtestsvuerun-20261013-093701#15081

Issue #15081 Merged fix PR #15082 Run 13 Oct 2026 · run-20261013-093701 vuejs/core

SSR hydration warning: dynamic props on SVG elements are patched as properties instead of attributes

Worse

The merged fix was judged better than our patch.

In this judgment, Patch A = our agent, Patch B = the merged fix.

Both patches fix the root cause the same way. In hydrateElement, the forced patchProp call now passes the element's real namespace ('svg' or 'mathml') instead of undefined. runtime-dom's shouldSetAsProp then routes SVG props through setAttribute rather than property assignment, which resolves the read-only viewBox/width errors. Both derive the namespace from the element's own namespaceURI, so <foreignObject> is correctly treated as SVG. Correctness is effectively equal. Patch A also passes the namespace on the onClick-only branch. That is harmless but irrelevant, because event keys are handled before the namespace matters. Its null-guarded helper is slightly more defensive than B's `!` assertion, but elements in a real DOM always have a namespaceURI.

The tests are the deciding difference. Patch A's tests hydrate with client values identical to the server markup and then check the attributes. Those attributes already exist from SSR, so the assertions pass whether or not patching happened. The only discriminating check is that 'Failed setting prop' is not warned. That depends on jsdom exposing getter-only viewBox/width on SVG elements, which jsdom largely does not implement. A's tests therefore likely pass before the fix as well. Patch B uses different client values (48 vs 24), so the patch is observable. Its foreignObject test explicitly defines a getter-only `width` property to simulate the real browser behavior. Before the fix, Vue would try property assignment, fail, and leave the attribute at '24'. After the fix it uses setAttribute and gets '48'. That is a genuine regression test that fails before and passes after. B's first SVG test is weaker for the same jsdom reason, but the second one makes B's coverage meaningful. Both changes are minimal in scope. B wins on test quality.

The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.

Solve

5m 25s

Wall-clock time in the container

Full test suite

No new failures

1,729 passed · 1 skipped · 1,732 total

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

76vs 67 merged

Changed lines, ours vs merged

Version

3.5.39

Reproduction link

stackblitz.com

Steps to reproduce

  1. Open the reproduction.
  2. Open the browser devtools Console.
  3. Observe the [Vue warn]: Failed setting prop … error logged during hydration.

What is expected?

During hydration, dynamic props on SVG (and MathML) elements width, height, viewBox, etc. should be patched as attributes (via setAttribute) exactly as they are during normal client-side rendering. Hydration should be silent.

What is actually happening?

Since 3.5.39, dynamic props on SVG elements are patched as DOM properties during hydration, which throws for read-only SVG IDL properties:

[Vue warn]: Failed setting prop "viewBox" on <svg>: value 0 0 24 24 is invalid.
TypeError: Cannot set property viewBox of #<SVGSVGElement> which has only a getter
    at patchDOMProp
    at patchProp
    at hydrateElement
    at hydrateNode
    at hydrateSubTree
    at <App>

Nothing is visually broken but the console is flooded with warnings.


We ran across this issue in a Nuxt app but I believe the issue is coming from Vue core

<!-- generated by vue-issues. DO NOT REMOVE -->

The two patches

Our patch+73 −3
packages/runtime-core/__tests__/hydration.spec.tsindex 144473dd3..f82984f59 100644@@ -2776,5 +2776,59 @@ describe('SSR hydration', () => {       expect(el.getAttribute('id')).toBe('client')       expect(el.getAttribute('value')).toBe('server')     })++    test('patch dynamic SVG props as attributes when hydrating', () => {+      const { container } = mountWithHydration(+        `<svg viewBox="0 0 24 24" width="24" class="icon"><foreignObject width="10"></foreignObject></svg>`,+        () => (+          openBlock(),+          createElementBlock(+            'svg',+            { viewBox: '0 0 24 24', width: '24', class: 'icon' },+            [+              createElementVNode(+                'foreignObject',+                { width: '10' },+                null,+                PatchFlags.PROPS,+                ['width'],+              ),+            ],+            PatchFlags.CLASS | PatchFlags.PROPS,+            ['viewBox', 'width'],+          )+        ),+      )+      const svg = container.firstChild as SVGSVGElement+      const foreignObject = svg.firstChild as Element+      expect(svg.getAttribute('viewBox')).toBe('0 0 24 24')+      expect(svg.getAttribute('width')).toBe('24')+      expect(svg.getAttribute('class')).toBe('icon')+      expect(foreignObject.getAttribute('width')).toBe('10')+      expect(`Failed setting prop`).not.toHaveBeenWarned()+      expect(`Hydration`).not.toHaveBeenWarned()+    })++    test('patch SVG event listeners when hydrating', () => {+      const fn = vi.fn()+      const { container } = mountWithHydration(+        `<svg viewBox="0 0 24 24"></svg>`,+        () => (+          openBlock(),+          createElementBlock(+            'svg',+            { viewBox: '0 0 24 24', onClick: fn },+            null,+            PatchFlags.PROPS | PatchFlags.NEED_HYDRATION,+            ['viewBox', 'onClick'],+          )+        ),+      )+      const svg = container.firstChild as SVGSVGElement+      triggerEvent('click', svg)+      expect(fn).toHaveBeenCalledTimes(1)+      expect(svg.getAttribute('viewBox')).toBe('0 0 24 24')+      expect(`Failed setting prop`).not.toHaveBeenWarned()+    })   }) })packages/runtime-core/src/hydration.tsindex c315ab940..9d59076a2 100644@@ -32,7 +32,11 @@ import {   normalizeStyle,   stringifyStyle, } from '@vue/shared'-import { type RendererInternals, needTransition } from './renderer'+import {+  type ElementNamespace,+  type RendererInternals,+  needTransition,+} from './renderer' import { setRef } from './rendererTemplateRef' import {   type SuspenseBoundary,@@ -72,6 +76,17 @@ const isSVGContainer = (container: Element) => const isMathMLContainer = (container: Element) =>   container.namespaceURI!.includes('MathML') +// namespace of the element itself (unlike getContainerType, a <foreignObject>+// element is still an SVG element), used when patching its props+const getElementNamespace = (el: Element): ElementNamespace => {+  const ns = el.namespaceURI+  if (ns) {+    if (ns.includes('svg')) return 'svg'+    if (ns.includes('MathML')) return 'mathml'+  }+  return undefined+}+ const getContainerType = (   container: Element | ShadowRoot, ): 'svg' | 'mathml' | undefined => {@@ -500,6 +515,7 @@ export function createHydrationFunctions(           patchFlag & (PatchFlags.FULL_PROPS | PatchFlags.NEED_HYDRATION)         ) {           const isCustomElement = el.tagName.includes('-')+          const namespace = getElementNamespace(el)           for (const key in props) {             // check hydration mismatch             if (@@ -520,7 +536,7 @@ export function createHydrationFunctions(               (isCustomElement && !isReservedProp(key)) ||               (dynamicProps && dynamicProps.includes(key))             ) {-              patchProp(el, key, null, props[key], undefined, parentComponent)+              patchProp(el, key, null, props[key], namespace, parentComponent)             }           }         } else if (props.onClick) {@@ -531,7 +547,7 @@ export function createHydrationFunctions(             'onClick',             null,             props.onClick,-            undefined,+            getElementNamespace(el),             parentComponent,           )         } else if (patchFlag & PatchFlags.STYLE && isReactive(props.style)) { 
Merged fix · PR #15082+66 −1
packages/runtime-core/__tests__/hydration.spec.tsindex 144473dd3..df0114065 100644@@ -2755,6 +2755,66 @@ describe('SSR hydration', () => {       }     }) +    test('force patch svg dynamic props with correct namespace when hydrating', () => {+      __DEV__ = false+      try {+        const { container } = mountWithHydration(+          `<svg width="24" height="24" viewBox="0 0 24 24"></svg>`,+          () =>+            createElementVNode(+              'svg',+              { width: 48, height: 48, viewBox: '0 0 48 48' },+              null,+              PatchFlags.PROPS,+              ['width', 'height', 'viewBox'],+            ),+        )+        const el = container.firstChild as Element+        expect(el.namespaceURI).toContain('svg')+        expect(el.getAttribute('width')).toBe('48')+        expect(el.getAttribute('height')).toBe('48')+        expect(el.getAttribute('viewBox')).toBe('0 0 48 48')+      } finally {+        __DEV__ = true+      }+    })++    test('force patch foreignObject dynamic props with correct namespace when hydrating', () => {+      __DEV__ = false+      try {+        const container = document.createElement('div')+        container.innerHTML =+          '<svg><foreignObject width="24"></foreignObject></svg>'+        const el = container.querySelector('foreignObject')!+        expect(el.namespaceURI).toContain('svg')+        // jsdom doesn't implement SVGForeignObjectElement.width.+        Object.defineProperty(el, 'width', {+          configurable: true,+          get: () => 24,+        })++        createSSRApp({+          render: () => (+            openBlock(),+            createElementBlock('svg', null, [+              (openBlock(),+              createElementBlock(+                'foreignObject',+                { width: 48 },+                null,+                PatchFlags.PROPS,+                ['width'],+              )),+            ])+          ),+        }).mount(container)++        expect(el.getAttribute('width')).toBe('48')+      } finally {+        __DEV__ = true+      }+    })+     test('only patches declared dynamic props when hydrating', () => {       const { container } = mountWithHydration(         `<div data-allow-mismatch="attribute" id="server" value="server"></div>`,packages/runtime-core/src/hydration.tsindex c315ab940..405a5db93 100644@@ -500,6 +500,11 @@ export function createHydrationFunctions(           patchFlag & (PatchFlags.FULL_PROPS | PatchFlags.NEED_HYDRATION)         ) {           const isCustomElement = el.tagName.includes('-')+          const namespace = el.namespaceURI!.includes('svg')+            ? 'svg'+            : el.namespaceURI!.includes('MathML')+              ? 'mathml'+              : undefined           for (const key in props) {             // check hydration mismatch             if (@@ -520,7 +525,7 @@ export function createHydrationFunctions(               (isCustomElement && !isReservedProp(key)) ||               (dynamicProps && dynamicProps.includes(key))             ) {-              patchProp(el, key, null, props[key], undefined, parentComponent)+              patchProp(el, key, null, props[key], namespace, parentComponent)             }           }         } else if (props.onClick) {