fix(custom-elements): stop overriding the provides object of the internal instance

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.
This commit is contained in:
Adrian Cerbaro 2025-04-17 23:04:11 -03:00
parent 6694878825
commit 87cda11c29
2 changed files with 2 additions and 5 deletions

View File

@ -23,10 +23,8 @@ export function provide<T, K = InjectionKey<T> | 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)
}

View File

@ -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)
}
}