framework7io / framework7

Full featured HTML framework for building iOS & Android apps
http://framework7.io
MIT License
18.04k stars 3.23k forks source link

fix(svelte): Custom icon reset class on update #4126

Closed sukram230799 closed 1 year ago

sukram230799 commented 1 year ago

If I dynamically change a custom icon (themeIcon), the class would be appended instead of replaced. This is because we only set the class to true via classes[value] = true; but never delete the old classes that are no longer passed as arguments. To fix this, I just replace the classes object with a new one.

<Link
  ...
  iconMd={pinnedState ? "icon:mdi mdi-pin-off" : "icon:mdi mdi-pin"}
  ...
/>

Example before change of pinnedState

<i class="icon mdi mdi-pin" style=""> </i>

Example wrong

<i class="icon mdi mdi-pin mdi mdi-pin-off" style=""> </i>

Example correct

<i class="icon mdi mdi-pin-off" style=""> </i>
nolimits4web commented 1 year ago

Thank you! The fix should be done in a bit different way, so i pushed the new fix for this