Font-awesome: Vue.js icon doesn't work when you use v-if on the element or parent

Created on 8 Mar 2018  路  9Comments  路  Source: FortAwesome/Font-Awesome

Describe the problem

Vue.js icon doesn't work when you use v-if on the element or parent.

I guess the javascript takes the element and places it on the DOM again. I'm not quite sure exactly what its doing.

The URL of the

What did you expect?

Normal behavior from vue.js: element uses instruction v-if to show or not depending of the state of the variable.

What version and implementation are you using?

Version: v5.0.8
Browser and version: CDN

  • [x] SVG with JS

Reproducible test case

https://jsfiddle.net/dacastro4/hedm6403/11/

waiting for feedback

Most helpful comment

I can reproduce this

Using FontAwesome 5 CSS via CDN in a Vue.js app. Anytime I use a <i class="fa fa-blah"></i> inside an element with v-if I get weird results

Same with updating a class with :class to change the icon - it doesn't work reactively, even if the Vue property reacts properly, the fa icon doesn't change

All 9 comments

I can reproduce this

Using FontAwesome 5 CSS via CDN in a Vue.js app. Anytime I use a <i class="fa fa-blah"></i> inside an element with v-if I get weird results

Same with updating a class with :class to change the icon - it doesn't work reactively, even if the Vue property reacts properly, the fa icon doesn't change

@robmadole could you please take a look here?

We have a Vue component that we've created to work with Vue.

https://github.com/FortAwesome/vue-fontawesome

Will that work @dacastro4 @benc-uk ?

@robmadole yes, changing to the vue component solves the issue but this would be a SVG JS issue, right?

SVG with JS is not compatible with Vue.js (that's why we created the component 馃槈 )

Touch茅... then I think we need some sort of heads up or something.
Awesome job! this new font awesome rocks :)

Thank you so much!!

Oh yes, agreed. The docs need to point people in the right direction a little better. We're working on that.

I've been beating my head on this for hours as I thought I was doing something wrong with Vue which somehow was multiplying my icons, so happy to have a solution.

It is great that you have developed a fa component. But its is the question whether we need new vue components for every bug we find. I would prefer to find a solution instead of installing more an more components with a minimal extra value.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sezeresen picture sezeresen  路  3Comments

rufengch picture rufengch  路  3Comments

jakuuub picture jakuuub  路  3Comments

omnimint picture omnimint  路  3Comments

AndersDK12 picture AndersDK12  路  3Comments