Skip to content
This repository has been archived by the owner on Jul 10, 2022. It is now read-only.

Add warning & doc entry about conflicts with the "style" attribute on Vuebar elements. #34

Open
guykatz opened this issue Oct 9, 2017 · 4 comments

Comments

@guykatz
Copy link

guykatz commented Oct 9, 2017

so this took me a while to reproduce: https://jsfiddle.net/gkatz/cadoqgaf/
in the jsfiddle above, go to the <div v-if="loading" style=""> and simply remove the style attribute and everything will work, this also happens with other regular attributes.
I am no JS expert and so I sis not debug the problem.
all of my templates look the same, I have many components which show a loading spinner until mounted so this affects all my app. any suggestions?

@DominikSerafin
Copy link
Owner

Hey @guykatz, thanks for filling in the issue.

Vuebar doesn't init in this case because style attribute is used on the element w v-bar directive.

And what happens here is probably Vue render overwriting Vuebar style attributes with that empty style="".

What I will do from my side is to add information about this in the documentation and add warning in the Vuebar itself.

But this behavior can't be fixed because it's needed for Vuebar to work at all. So I just suggest you to wrap your Vuebar container or not using inline styles on the Vuebar elements.

@DominikSerafin DominikSerafin self-assigned this Oct 9, 2017
@DominikSerafin DominikSerafin changed the title vuabar not working with certain templates with attributes on elements [weird]... Add warning & doc entry about conflicts with the "style" attribute on Vuebar elements. Oct 9, 2017
@guykatz
Copy link
Author

guykatz commented Oct 9, 2017

thanks for the quick answer but I think you have missed something
there is no v-bar directive on the element with the style. it is a sibling element. the vuebar directive is on another element. I do not understand why a sibling element would be affected at all. can you ellaborate?
thanks

@DominikSerafin
Copy link
Owner

DominikSerafin commented Oct 9, 2017

Hi @guykatz

Oh yeah, you're right I have missed it. But actually it's still kind of applies what I've said.

The problem here is that you've missed key attribute on these elements.

If you don't provide key for the v-if/v-else-if/v-else and for looped elements with v-for then Vue might sometime not update these elements correctly because Vue doesn't rerender all elements on update but reuses elements already rendered.

So Vue probably still treated both of these elements as one - hence the style conflict.

https://vuejs.org/v2/api/#key

See updated JSFiddle: https://jsfiddle.net/cadoqgaf/2/

@guykatz
Copy link
Author

guykatz commented Oct 9, 2017

oh wow, i had no idea about this applying to other elements except of loop.
thanks for pointing this out.

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

No branches or pull requests

2 participants