Skip to content
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

$attrs are not triggering render update when inside slots #1346

Closed
AlexandreBonaventure opened this issue Jun 11, 2020 · 2 comments
Closed
Labels
🐞 bug Something isn't working

Comments

@AlexandreBonaventure
Copy link
Contributor

Version

3.0.0-beta.14

Reproduction link

https://jsfiddle.net/Lvo5aks1/

Steps to reproduce

Rendering $attrs inside a wrapper component (with default slot).
It does not seem to be collected as a reactive dependency.

What is expected?

$attrs should be reactive like any other reactive object
see here https://jsfiddle.net/tpewsd71/

What is actually happening?

It does not update/trigger a re-render of the slot

Comment

Maybe this is expected, because I think in Vue3 $attrs is not actually a reactive object but just a proxy, thus this is why it is not triggering update. However, coming from Vue 2 where this was a reactive object, it is confusing that it is not anymore and is probably going to break some components.
I wonder then if there is an official recommendation when dealing with this kind of use-case.

@AlexandreBonaventure AlexandreBonaventure changed the title $attrs are triggering render update when inside slots $attrs are not triggering render update when inside slots Jun 11, 2020
@underfin
Copy link
Member

underfin commented Jun 12, 2020

I debuged for this.The slot not updated because patch wrapper-component is skiped.The shouldUpdateComponent returned false.

Maybe we should marked patch flag DYNAMIC_SLOTS for wrapper-component vnode when compiled the slot which has dynamic content.

<wrapper-component>
          <p>
            attrs inside slot: {{ $attrs }}
          </p>
        </wrapper-component>
 return (_openBlock(), _createBlock(_component_wrapper_component, null, {
    default: _withCtx(($attrs) => [
      _createVNode("p", null, " attrs inside slot: " + _toDisplayString($attrs), 1 /* TEXT */)
    ]),
    _: 1
  }))

@AlexandreBonaventure
Copy link
Contributor Author

As a workaround one can force the update of the wrapper component by updating an attribute:

<wrapper-component :trigger="() => Symbol('')">
     <p>
            attrs inside slot: {{ $attrs }}
     </p>
</wrapper-component>

https://jsfiddle.net/7exn32Lo/

@yyx990803 yyx990803 added the 🐞 bug Something isn't working label Jun 12, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants