Backtestsvuerun-20261005-124535#15081

Issue #15081 Merged fix PR #15082 Run 5 Oct 2026 · run-20261005-124535 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 make the same core fix. During hydration they derive 'svg' or 'mathml' from the element's own namespaceURI and pass it to patchProp in place of `undefined`. This resolves the root cause, because patchProp then takes the SVG/MathML attribute path, just as in client rendering. Both correctly treat `<foreignObject>` itself as an SVG element by reading el.namespaceURI rather than reusing getContainerType. A is slightly more defensive about a null namespaceURI and puts the logic in a named helper. B uses a non-null assertion, but elements hydrated from parsed HTML always have a namespace, so the practical risk is negligible. On correctness they are effectively equal.

The tests are the deciding factor. jsdom implements few SVG IDL properties and no MathML ones. In A's tests, `viewBox`, `width` and `display` are probably not present as properties, so `shouldSetAsProp` would fall back to setAttribute even without the fix. A's tests therefore likely pass on the unfixed code and don't guard the regression. B's foreignObject test defines a getter-only `width` property on the element, explicitly to work around jsdom's gap. This reproduces the issue's read-only IDL scenario: without the fix, patchDOMProp tries to assign the property, fails, and the attribute stays at 24. With the fix, the attribute becomes 48. B also uses differing server and client values, so the assertions show the patch actually happened. That makes B's test a genuine regression test that fails before the fix and passes after.

Scope is equally minimal in both. A's helper is slightly cleaner craft, but B's meaningfully stronger test coverage outweighs that.

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

6m 43s

Wall-clock time in the container

Full test suite

No new failures

3,614 passed · 6 skipped · 3,622 total

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

99vs 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+98 −1
packages/runtime-core/__tests__/hydration.spec.tsindex 144473dd3..e696c07f6 100644@@ -2776,5 +2776,91 @@ describe('SSR hydration', () => {       expect(el.getAttribute('id')).toBe('client')       expect(el.getAttribute('value')).toBe('server')     })++    test('patches dynamic props on SVG elements as attributes when hydrating', () => {+      const { container } = mountWithHydration(+        `<svg viewBox="0 0 24 24" class="icon" width="24">` ++          `<use xlink:href="#a"></use>` ++          `<foreignObject width="10"><div title="t"></div></foreignObject>` ++          `</svg>`,+        () => (+          openBlock(),+          createElementBlock(+            'svg',+            { viewBox: '0 0 24 24', class: 'icon', width: '24' },+            [+              createElementVNode(+                'use',+                { 'xlink:href': '#a' },+                null,+                PatchFlags.PROPS,+                ['xlink:href'],+              ),+              createElementVNode(+                'foreignObject',+                { width: '10' },+                [+                  createElementVNode(+                    'div',+                    { title: 't' },+                    null,+                    PatchFlags.PROPS,+                    ['title'],+                  ),+                ],+                PatchFlags.PROPS,+                ['width'],+              ),+            ],+            PatchFlags.CLASS | PatchFlags.PROPS,+            ['viewBox', 'width'],+          )+        ),+      )+      const svg = container.firstChild as SVGSVGElement+      expect(svg.getAttribute('viewBox')).toBe('0 0 24 24')+      expect(svg.getAttribute('width')).toBe('24')+      expect(svg.getAttribute('class')).toBe('icon')+      const use = svg.firstChild as Element+      expect(use.getAttributeNS('http://www.w3.org/1999/xlink', 'href')).toBe(+        '#a',+      )+      const foreignObject = svg.lastChild as Element+      expect(foreignObject.getAttribute('width')).toBe('10')+      expect((foreignObject.firstChild as HTMLElement).title).toBe('t')+      expect(`Failed setting prop`).not.toHaveBeenWarned()+      expect(`Hydration`).not.toHaveBeenWarned()+    })++    test('patches dynamic props on MathML elements as attributes when hydrating', () => {+      const { container } = mountWithHydration(+        `<math display="block"><mi mathvariant="bold">x</mi></math>`,+        () => (+          openBlock(),+          createElementBlock(+            'math',+            { display: 'block' },+            [+              createElementVNode(+                'mi',+                { mathvariant: 'bold' },+                'x',+                PatchFlags.PROPS,+                ['mathvariant'],+              ),+            ],+            PatchFlags.PROPS,+            ['display'],+          )+        ),+      )+      const math = container.firstChild as Element+      expect(math.getAttribute('display')).toBe('block')+      expect((math.firstChild as Element).getAttribute('mathvariant')).toBe(+        'bold',+      )+      expect(`Failed setting prop`).not.toHaveBeenWarned()+      expect(`Hydration`).not.toHaveBeenWarned()+    })   }) })packages/runtime-core/src/hydration.tsindex c315ab940..2ede778a1 100644@@ -81,6 +81,16 @@ const getContainerType = (   return undefined } +// namespace of the element itself (unlike getContainerType, a+// <foreignObject> is still an SVG element even though its children are not)+const getElementNamespace = (el: Element): 'svg' | 'mathml' | undefined => {+  const ns = el.namespaceURI+  if (!ns) return undefined+  if (ns.includes('svg')) return 'svg'+  if (ns.includes('MathML')) return 'mathml'+  return undefined+}+ export const isComment = (node: Node): node is Comment =>   node.nodeType === DOMNodeTypes.COMMENT @@ -500,6 +510,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 +531,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) { 
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) {