dugarab / jsplumb

Automatically exported from code.google.com/p/jsplumb
0 stars 0 forks source link

hoverClass not working #277

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I've been using jsPlumb for a project, and it's awesome. However, I have 
noticed that the hoverClass property never gets triggered. In fact if you use 
firebug it's actually possible to see errors being thrown.

I've put together a jsFiddle - http://jsfiddle.net/VkTAL/3/

Also, I was a little desperate for the fix so had a trawl through the code and 
found/fixed the issue, though it may be hacky.

I changed this code section (lines 9946 - 9957)

addClass : function(el, clazz) {
    el = jsPlumb.CurrentLibrary.getElementObject(el);
    try {
        if (el[0].className.constructor == SVGAnimatedString) {
            jsPlumb.util.svg.addClass(el[0], clazz);
        }
    }
    catch (e) {
        // SVGAnimatedString not supported; no problem.
    }
    el.addClass(clazz);
},

to

addClass : function(el, clazz) {
    el = jsPlumb.CurrentLibrary.getElementObject(el);
    try {
        if (el[0].className.constructor == SVGAnimatedString) {
            jsPlumbUtil.svg.addClass(el[0], clazz);
        }
        el.addClass(clazz);
    }
    catch (e) {
        // SVGAnimatedString not supported; no problem.
    }
},

I also changed the removeClass function to be similar. It seems to work now and 
the el.addClass being inside the try-catch stops firebug throwing errors.

Thanks for such an awesome plugin

Original issue reported on code.google.com by mattdavi...@googlemail.com on 13 Sep 2012 at 10:57

GoogleCodeExporter commented 8 years ago
i'll take a look at this. what browser did you test this fix in? the try/catch 
is there, as far as i recall, to cater for IE<9, in which SVGAnimatedString is 
not available. So the fix as you've written it would break those older IE 
browsers, i think.  but like i said, i will take a look.

Original comment by simon.po...@gmail.com on 16 Sep 2012 at 9:20

GoogleCodeExporter commented 8 years ago
I was using a very old version of Firefox at work (probably about v3).

I've just tried it on Firefox v15 at home, and you're correct the try-catch 
isn't required anymore. Firefox v15 doesn't throw any errors when the try-catch 
isn't around the el.addClass(clazz); line.

Original comment by mattdavi...@googlemail.com on 16 Sep 2012 at 10:02

GoogleCodeExporter commented 8 years ago
The main change, which I forgot to highlight in my first post, wasn't the 
change to try-catch. It was the change to this line;

jsPlumb.util.svg.addClass(el[0], clazz);

to

jsPlumbUtil.svg.addClass(el[0], clazz);

Not sure if you spotted that in the original post. Thanks

Original comment by mattdavi...@googlemail.com on 16 Sep 2012 at 10:05

GoogleCodeExporter commented 8 years ago
oh right, ha! no i didn't see the difference at all. now it all makes sense.

Original comment by simon.po...@gmail.com on 16 Sep 2012 at 10:06

GoogleCodeExporter commented 8 years ago
fixed in 1.3.15 dev.

Original comment by simon.po...@gmail.com on 16 Sep 2012 at 10:08

GoogleCodeExporter commented 8 years ago
1.3.15 was released today.

Original comment by simon.po...@gmail.com on 24 Sep 2012 at 1:28