Skip to content

Missing classes in vuetify element when shallowMount #883

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

Closed
trollepierre opened this issue Aug 1, 2018 · 4 comments
Closed

Missing classes in vuetify element when shallowMount #883

trollepierre opened this issue Aug 1, 2018 · 4 comments
Labels

Comments

@trollepierre
Copy link
Contributor

trollepierre commented Aug 1, 2018

Version

1.0.0-beta.22

Reproduction link

https://codesandbox.io/s/nn2p0w8300

Steps to reproduce

When shallowMounting a with a class="my-custom-class", I cannot find this element through wrapper.find(.my-custom-class) + this class is not present in snapshot

<template>
  <v-container class="my-custom-class">
    
  </v-container>
</template>

What is expected?

<v-container-stub
  class="my-custom-class"
/>

What is actually happening?

<v-container-stub
  tag="div"
/>

Also I cannot do any find(".my-custom-class"). That is a regression compared to beta 20.

ps:
I don't care about tag="div" in this issue. Maybe it could be better to remove Vuetify prop (but it is a "could", not a "must" have in this bug)

@trollepierre trollepierre changed the title No class in snapshot of vuetify component Missing classes in vuetify element when shallowMount Aug 1, 2018
@eddyerburgh eddyerburgh added the bug label Aug 3, 2018
@eddyerburgh
Copy link
Member

Thanks for the bug report.

I'll fix the issue with the class not rendering.

The other issue, of the class not working as a selector, is intended behavior. You should select components using a component selector, name selector, or ref selector. Other selectors are not supported.

@trollepierre
Copy link
Contributor Author

trollepierre commented Aug 3, 2018

In the .find() documentation, I can read: Use any valid selector.

In the selector documentation, I can read:

CSS Selectors
Mount handles any valid CSS selector:
tag selectors (div, foo, bar)
class selectors (.foo, .bar)
attribute selectors ([foo], [foo="bar"])
id selectors (#foo, #bar)
pseudo selectors (div:first-of-type)

So I believe CSS selectors should be supported selectors.

=> Anyway I believe that issue with class not rendering will fix it.

@eddyerburgh
Copy link
Member

Sorry that the docs are unclear, I'll rewrite them to improve clarity.

The issue won't be fixed, if it was working previously it was a bug. CSS selectors are used to match rendered HTMLElements, stubbed components don't render HTMLElements, so a class selector won't work.

@blairdow
Copy link

blairdow commented Nov 13, 2018

Hi @eddyerburgh here to say the docs are still unclear on this in my opinion. Particularly the part about descendent combinators, makes it seems like you can use find or contains on component rendered html. Maybe a sentence to the effect of what you said above describing how stubbed components dont render HTMLElements so a class selector wont work there and to use the component name instead.

Mount handles any valid CSS selector:

tag selectors (div, foo, bar)
class selectors (.foo, .bar)
attribute selectors ([foo], [foo="bar"])
id selectors (#foo, #bar)
pseudo selectors (div:first-of-type)
You can also use combinators:

direct descendant combinator (div > #bar > .foo)
general descendant combinator (div #bar .foo)
adjacent sibling selector (div + .foo)
general sibling selector (div ~ .foo)

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

No branches or pull requests

3 participants