Backtestsvuerun-20261005-124535#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.
The core complaint is that defineCustomElement replaces built-in Element members like `tagName`. Patch A fixes this; Patch B only warns about it. Patch A: - Correctness: it stops `Object.defineProperty` from shadowing any key in `HTMLElement.prototype`, so `tagName` stays the real tag name and methods like `click` and `focus` keep working. The prop still works through its attribute. It also adds a `patchProp` branch so a Vue parent rendering the CE can still pass these props, including object values like `title`, via `_setProp`. It applies the same guard to exposed members. This resolves the issue at its root while keeping the prop usable, which matches the reporter's first expectation: the attribute without a conflicting property. - Tests: they assert that `tagName` and `click` stay native, that there is no own descriptor, that attribute updates still re-render, that Vue-parent object props work, and that the warnings fire. These would fail before the change. - Risk: a breaking-behavior concern for anyone relying on property access for props named like native members (e.g. `id`, `title`). It mitigates this with a dev warning and the patchProp path. Patch B: - Correctness: it only adds a dev warning and still overwrites the native member. Its own test asserts `e.tagName` becomes `'foo'` and `hasAttribute` becomes an object, which locks in the broken behavior the issue complains about. - A warning is one acceptable outcome named in the issue, but it leaves the element in a broken state (e.g. `hasAttribute` is no longer callable, which can break other libraries and DOM code). - Tests: they mostly verify the warning text, plus an unrelated extra assertion. On correctness, which is weighted highest, Patch A clearly wins. Its added `patchProp` complexity is justified, and its tests are more meaningful.
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
10m 5s
Wall-clock time in the container
Full test suite
No new failures
3,667 passed · 6 skipped · 3,673 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
131vs 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.