Backtestsvuerun-20261013-093701#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 issue is that defineCustomElement silently defines an own `tagName` property that shadows the native `Element.prototype.tagName`. The reporter would accept either outcome: only the attribute is created with no matching property, or Vue warns about the clobbering. Patch A fixes the root cause: - It skips `Object.defineProperty` for declared props that already exist on the element's prototype chain, so native members like `tagName` and `click` keep working. - It emits a dev warning explaining that the prop can still be passed via its attribute or via Vue vnode props. - It deletes any pre-upgrade own property so the native member is not shadowed. - Because those props no longer have an element property, it adds a `patchProp` branch (`isNativeMemberPropForVueCE` → `_setDeclaredProp`). This keeps Vue templates and render functions passing camelCase, hyphenated and `.`-prefixed props correctly, instead of falling back to native property sets or attribute stringification. - It also tightens the expose path (`key in this` instead of `hasOwn`) so `expose()` cannot shadow native members either. - Its tests are behavioral and would fail before the change. They check that `e.tagName` keeps its native value, `click` stays a function, no own property is created, attribute and vnode updates still reach the component (including after reactive changes), and pre-upgrade properties are dropped. Patch B only adds a dev-mode warning and still overrides the native member. Its own test asserts `e.tagName` is 'foo', which codifies the breakage the issue complains about. That technically meets the minimal "or a warning" fallback, but the hazard remains: anything that reads `tagName` (or calls a shadowed method like `hasAttribute`) still breaks at runtime. Its tests mainly check that the warning fires, plus one unrelated assertion added to an existing test. Patch A carries some behavior-change risk. Props named after native members such as `title` or `id` no longer get Vue-managed element properties, so imperative non-string assignment changes semantics. However, reflected attributes still flow through to the prop, and Vue-rendered usage is explicitly preserved. On balance, A resolves the reported problem at its source with careful edge handling and stronger tests. B only surfaces it.
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
7m 45s
Wall-clock time in the container
Full test suite
No new failures
703 passed · 1 skipped · 704 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
165vs 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.