Skip to content

Dev: Hint in console when v-show used on element with the inline 'display: none;' #3484

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
oaleynik opened this issue Aug 19, 2016 · 5 comments

Comments

@oaleynik
Copy link

oaleynik commented Aug 19, 2016

<div v-show="foo" style="display: none;"></div>

v-show will be flipping none to none. It is developer's mistake, but feels like v-show doesn't work as expected.

Vue version: 2.0.0-rc.2

@miljan-aleksic
Copy link

As stated in the changelog, v-show now respects the original display value of the element. Why would you set it to none?

@oaleynik
Copy link
Author

Indeed. This is irrational. We've seen situation when display: none was set in original design and after attaching v-show nobody removed display: none;. Would be nice to see some hint in console about this. We actually faced this with server side rendering where v-show just sets display: none; and goes away.

@miljan-aleksic
Copy link

The change is ment to fix the situation where 'display: none' is set in the CSS, while just removing the display from dom would keep it invisible. It does make sense to completely remove it if the display is set to none, though.

@chrisvfritz, what do you think?

@oaleynik
Copy link
Author

oaleynik commented Aug 19, 2016

@miljan-aleksic thanks! This is exactly the topic of debate in the office. What should be happening in this case? Drop inline CSS. What should be set back when v-show evaluates to true then? Or respect original inline value?
IMO respect original inline value is the correct behaviour because engineer dictates what should be happening, not library. Instead of inline CSS some class with the display: none; can be used. In this case inline display: none; which will be set by v-show will override the value from the class.

The only thing we agreed after debate is that small warning from Vue in the console (when in devmode of course) will not hurt :)

@yyx990803
Copy link
Member

yyx990803 commented Aug 19, 2016

I think v-show should just ignore inline display: none, because

  1. using them together doesn't make sense, so overriding it is the only logical behavior;
  2. it needs to be able to override this when this value is itself set by v-show during SSR.

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

3 participants