-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
fix(custom-element): 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
base: main
Are you sure you want to change the base?
fix(custom-element): allow injecting values from app context in nested elements (fix #13212) #13219
Conversation
…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
…ontext Calling `_inheritParentContext` inside `_setParent` should be sufficient.
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
…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.
WalkthroughThe changes update the dependency injection context handling for Vue custom elements. They refactor how Changes
Sequence Diagram(s)sequenceDiagram
participant ParentCustomElement
participant ChildCustomElement
participant AppContext
ParentCustomElement->AppContext: provide('key', value)
ChildCustomElement->AppContext: inherit provides via prototype chain
ChildCustomElement->AppContext: provide('key', newValue)
ChildCustomElement->AppContext: inject('key')
Note right of ChildCustomElement: Receives newValue (own), falls back to parent if not present
Assessment against linked issues
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
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
Summary by CodeRabbit
Bug Fixes
Tests
Refactor