Skip to content

Dependency Injection inheritance fails when provided after grandchildren are rendered. #13921

@benjamin-larsen

Description

@benjamin-larsen

Vue version

Commit b555f02, latest in main branch.

Link to minimal reproduction

https://play.vuejs.org/#eNrlVU2P2jAQ/SuWVYkgRYkWONGA2m330Er90La9+ULDAIbEjvzBUiH+e8c2ScmKROpq20N7i2eex8/vPStH+rqqkr0FOqWZzhWvDNFgbDVngpeVVIYcSaXkni+BnMhKyZIMED5o2m9kWd2cG0nqV27e4CUTTJx3Rozu4AejMWHUI8+HMjp0qJUVueFSEAUrBXoT5ThlSI5MEOI+kxcrqXL4Vi0XBqIhTj65bVkaCCNVXBgoqwL7uCIkC6ymhpcwY/Qt1hMhH6Iho/MskAy479YYPPhVXvB8h8iagdlw7cD3YZ2lAYibsvTiJBpTo3MpVnydbLUUqKJnzajjzQtQnyp3M83oNNzH9RZFIR/e+5pRFuK6nm8g312pb/XB1Rj9jFxA7VG3pmcWag0mtO++fIQDfjfNUi5tgeie5j1oWVjHMcBurVgi7QucZ/vOm83F+qu+OxgQur6UI+qQJ49nFF118nZd/RfdcTLx+9BMVLHJTXcOHWTUCtrIB+0iqOheTLjYQm7iOrUxkeIWMEDwQVqB9XoZ4tQKNSYLzdSGYGdBZm5eJGxRuMh1h7nhjnH2wNaBUTQks3lQwI1N9ovCAg4PPOtpPtX+NbT5/eb2vjex5Hv/QTxjcoO2HMNNT+iCq/tnM7r6bEgahqRhyuNX0NjR79+45d/47/r3p2zpy4XXJIx5bv9GHf6Nn+qft6Pfv0nLv8m/4d/z2jLusGXyVFu8yn2/55bq/5fYk8diXxfy9BPP2P6K

Steps to reproduce

Create 4 components, each a child of the other.
App -> 1 -> 2 -> 3 -> 4

App and Component 1 each provides a unique value for the key "test" on first render. When Component 2 is re-rendered provide a unique value for the key "test".

What is expected?

It should be expected that Component 4 inherits the new provided value of Component 2, but instead only Component 3 inherits.

What is actually happening?

When provide() is called, it creates a new Object with the prototype of the previous parent's providers, however when this is done in overlap like it is here, it skips one.

First Render:

  • Component 1 has Object.create(App.provides)
  • Component 2 has Component 1's provides
  • Component 3 has Component 2's provides (which is Component 1's provides)
  • Component 4 has Component 3's provides (which is Component 1's provides)

Second Render:

  • Component 1 has Object.create(App.provides)
  • Component 2 has Object.create(Component 1.provides)
  • Component 3 has Component 2's provides
  • Component 4 has Component 3's old provides (which is Component 1's provides) [Note: Here lies the issue.]

System Info

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.has workaroundA workaround has been found to avoid the problemneed discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions