-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
fix(custom-elements): allow injecting values from app context in nested elements (fix #13212) #13219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adrianbrs
wants to merge
4
commits into
vuejs:main
Choose a base branch
from
adrianbrs:fix/broken-provide-inject-in-nested-custom-elements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix(custom-elements): allow injecting values from app context in nested elements (fix #13212) #13219
adrianbrs
wants to merge
4
commits into
vuejs:main
from
adrianbrs:fix/broken-provide-inject-in-nested-custom-elements
+126
−8
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…sted elements Before this change, when a custom element was nested within another, the values provided via `configureApp` were ignored. Now, the provides object in the app context of a custom element inherits the provides object from its parent, allowing values to be injected properly using the app context in nested custom elements. Close vuejs#13212
adrianbrs
commented
Apr 17, 2025
…ontext Calling `_inheritParentContext` inside `_setParent` should be sufficient.
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-ssr
@vue/compiler-sfc
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
edison1105
reviewed
Apr 18, 2025
…rnal 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.
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🔨 p3-minor-bug
Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.
scope: custom elements
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this change, when a custom element was nested within another, the values provided via
configureApp
were ignored. Now, the provides object in the app context of a custom element inherits the provides object from its parent, allowing values to be injected properly using the app context in nested custom elements.Note
In this implementation, values provided in the
configureApp
method will take precedence over values injected from parent elements. I believe this should be the expected behavior, since each custom element should have its own scope, but we can discuss it further if needed.Close #13212
Playground:
https://deploy-preview-13219--vue-sfc-playground.netlify.app/#eNrdVk2P2jAQ/SuuL2QlIKraEw1ILeKwPXSrbm91D1EygGniWLZDkRD/vRNPPiDNIrqHql0OwZ55nnkzz3Zy5O+1nu5L4DMe2cRI7ZgFV2qWxWozF9zZg+ALoWSuC+PYkaWwlgqWpXVFvsogB+XGTKodJPivTbGXKbATW5siZyMMPHonlFBJoaxjD6UDw+ZDMYLgjs0X7CgUwx/B7TY2kCKewgcjMozuMGSHKuqgDcjPexip1AXGzz2GUAZLNooRh4BsjEWp3GPpNMHp9vXCVxCFODqz68WjJzZjR2J4ikJ9CfDr0O/J/e6+r/ig2/Pqu21WOBa2lijsaFGVp3H17Fq3lpvSAAobxFrfNQ7GcDatFWp7OWZtVwdh1E1E1W0lEGWsntRD6rKv4hZ52+ikA0b3g4nfeVWOf3wX+EJfxC7o5N2DMWiaXOjcQ1/KdcNmWG5lVkn3/x542tO+jr8p+IC8TXvlmgWvkvNW2ukGsEayTYCMjZC18r0FJMgTa8Z0UVfpMOut+eoW/1G+ZkP5Rjwn3ySplHlO1nplndsLXBOIQnoRYvtx4iDXWezAixEN9auWqe/zWTpBn+awiMIrzjr4IIQ49V0NqSg8487H+CqnW2G6s4XC973vmOBJkWuZgXnQTuLZERw3JCUVPM6y4udHb3OmBH/Q/ZotJD8G7Lvqa2GGg88GLJg9CN76XGxQRnKvHj/BAcetMy/SMkP0FecXsEVWVhwJ9qFUKdI+w3m29/5DRarNV7s6OFC2Kaoi2t2TguO3yfJK6R3dN9O3bQppLy6xyv2tkVhw3/lGB8HJ8b0+vSd++gXFBQq6