Backtestsvuerun-20261003-231210#12124
defineCustomElement can accidentally override members of the Element prototype
Better
Our patch was judged better than the merged fix.
In this judgment, Patch A = our agent, Patch B = the merged fix.
Patch A fixes the root cause. It never shadows readonly native members such as `tagName`, `nodeName` or `isConnected`. `isReadonlyNativeProp` walks the prototype chain and checks for a getter with no setter, or a non-writable data property. The declared prop still receives its value, through three paths: attribute changes via `_setAttr`, and parent bindings via a new `patchProp` branch that calls `_setShadowedProp`. That branch covers camelCase, kebab-case and `.prop` forms, plus unresolved async CEs. The same guard applies to exposed properties, which close a second override route. Its tests check that `e.tagName` keeps the real tag name, that no own descriptor is created, and that the prop still renders the attribute or bound value. They cover sync, async and expose cases, and would fail before the change. The main cost is some extra complexity in the hot `patchProp` path: `isPropOfVueCE` and `_setShadowedProp` run per key on Vue CEs. That is acceptable. Patch B only adds a dev warning and keeps the harmful behavior. Its own test asserts `e.tagName` becomes 'foo', so the element's `tagName` stays broken in production. Its check, `key in Object.getPrototypeOf(this)`, is also broad. It warns on writable reflected props like `id`, where overriding is mostly harmless. Its added assertion `expect(e.foo).toBe('foo2')` is unrelated. A warning is one of the issue's acceptable outcomes, but Patch A actually prevents the breakage the issue reports, so it is the more correct fix.
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
8m 19s
Wall-clock time in the container
Full test suite
No new failures
3,668 passed · 6 skipped · 3,674 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
190vs 79 merged
Changed lines, ours vs merged
The issue
View on GitHubVue version
3.4.5
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-aob5zf?file=index.html
Steps to reproduce
I defined a Vue component with tagName as a property, and used that, together with defineCustomElement to define the hello-world webcomponent.