neveldo / jQuery-Mapael

jQuery plugin based on raphael.js that allows you to display dynamic vector maps
https://www.vincentbroute.fr/mapael/
MIT License
1.01k stars 195 forks source link

JQuery can't add a class to an SVG element so use attr. #306

Closed la40 closed 7 years ago

la40 commented 7 years ago

The new cssClass option doesn't work. JQuery can't add a class to an SVG element so use attr. Read more here: https://stackoverflow.com/questions/8638621/jquery-svg-why-cant-i-addclass?answertab=votes#tab-top

neveldo commented 7 years ago

Hello @lachezargrigorov ,

Thanks for your contribution. However, it works fine with jQuery 3.1.1. I read in your stackoverflow thread that it's ok since jquery 2.2 and 1.12 :

The jQuery 2.2 and 1.12 Released post includes the following quote:

While jQuery is a HTML library, we agreed that class support for SVG elements could be useful. Users will now be able to call the .addClass(), .removeClass(), .toggleClass(), and .hasClass() methods on SVG. jQuery now changes the class attribute rather than the className property. This also makes the class methods usable in general XML documents. Keep in mind that many other things will not work with SVG, and we still recommend using a library dedicated to SVG if you need anything beyond class manipulation.

I think you should upgrade the jQuery version of your project instead if it's possible.

la40 commented 7 years ago

As you wish.