From 87cda11c292299d28d636289fe6790e257d19691 Mon Sep 17 00:00:00 2001 From: Adrian Cerbaro Date: Thu, 17 Apr 2025 23:04:11 -0300 Subject: [PATCH] fix(custom-elements): stop overriding the provides object of the internal instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The internal instance of a custom element already inherits the app context’s provides object via the prototype chain, so there’s no need to override it or add extra logic to the `provide` function. --- packages/runtime-core/src/apiInject.ts | 6 ++---- packages/runtime-dom/src/apiCustomElement.ts | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/runtime-core/src/apiInject.ts b/packages/runtime-core/src/apiInject.ts index 21beb1d3f..711c5d84d 100644 --- a/packages/runtime-core/src/apiInject.ts +++ b/packages/runtime-core/src/apiInject.ts @@ -23,10 +23,8 @@ export function provide | string | number>( // own provides object using parent provides object as prototype. // this way in `inject` we can simply look up injections from direct // parent and let the prototype chain do the work. - // #13212, custom elements inherit the provides object from appContext - const parentProvides = currentInstance.ce - ? currentInstance.appContext.provides - : currentInstance.parent && currentInstance.parent.provides + const parentProvides = + currentInstance.parent && currentInstance.parent.provides if (parentProvides === provides) { provides = currentInstance.provides = Object.create(parentProvides) } diff --git a/packages/runtime-dom/src/apiCustomElement.ts b/packages/runtime-dom/src/apiCustomElement.ts index 7b2afe566..cd21d0d1c 100644 --- a/packages/runtime-dom/src/apiCustomElement.ts +++ b/packages/runtime-dom/src/apiCustomElement.ts @@ -316,7 +316,6 @@ export class VueElement private _setParent(parent = this._parent) { if (parent) { this._instance!.parent = parent._instance - this._instance!.provides = this._instance!.appContext.provides this._inheritParentContext(parent) } }