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

When setProps() is called on a wrapper which renders a slot, the slot's content element gets destroyed #2067

Open
jsekulowicz opened this issue Apr 27, 2023 · 0 comments

Comments

@jsekulowicz
Copy link

jsekulowicz commented Apr 27, 2023

(Using @vue/test-utils 1.3.5).

Subject of the issue

tl;dr
I call wrapper.setProps() and the element (elm prop) in my slot disappears.

Background
My component operates on the element it gets into its slot - I need to grab the element's height in runtime.

In unit tests, I want to setProps to change the state of the component but once I do that, it loses the information about the element which was passed to its slot, as if I stopped passing the element.

Steps to reproduce

  1. Mount a component with non-empty slots, using either mount() or shallowMount().
  2. Call wrapper.setProps().
  3. See that the elm property inside of one of wrapper.vm.$slots is falsy. Before calling wrapper.setProps() it was not.

See the working and simplified example.

Expected behaviour

In the example, wrapper.vm.$slots.footer[0].elm should not be empty after calling wrapper.setProps().

Actual behaviour

In the example, wrapper.vm.$slots.footer[0].elm is empty after calling wrapper.setProps().

Possible Solution

Keep the elm property intact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant