This project is archived and is in readonly mode.

#526 ✓resolved
Alessandro Pironi

Problem in $$ function when using with SVG

Reported by Alessandro Pironi | December 19th, 2008 @ 05:12 PM | in 1.3.0 rc2 (closed)

When using SVG support in firefox, calling $$ function causes an error The problem seems to be in className attribute not being a String for some object, but instead a SVGAnimatedString object.

The error raises at line 2696 (mootools.core 1.2.1 not compressed):

return (self.className && self.className.contains(klass, ' '));

possible workaround:

return (self.className && (typeof self.className == 'string') && self.className.contains(klass, ' '));

Comments and changes to this ticket

  • gregg64

    gregg64 June 17th, 2009 @ 05:32 PM

    Rather than changing mootools, I added the following script to extend the offending attribute. This is something that should be fixed in mootools though.

    // Extend SVG element to have className method that mootools needs. if ($defined(SVGAnimatedString)) {

    SVGAnimatedString.prototype.contains = function(value) {
        return false;
    };
    

    }

  • Paul Williams

    Paul Williams August 2nd, 2009 @ 07:53 AM

    Using an adapted version of the above makes $$ work properly:

    SVGAnimatedString.prototype.contains = function(value) {
    return this.baseVal.contains( value); };

  • JT

    JT September 24th, 2009 @ 06:51 PM

    • Assigned user cleared.

    I'm getting this when I use that in any browser other than firefox:

    ReferenceError: Can't find variable: SVGAnimatedString

  • Jan Kassens

    Jan Kassens November 21st, 2009 @ 06:07 PM

    • Assigned user set to “Thomas Aylott”
    • State changed from “new” to “open”
    • Tag changed from class, core, selectors, svg to slick, svg

    Probably fixed in slick, but we should make sure its properly specced out.

  • Yorick Sijsling

    Yorick Sijsling January 31st, 2010 @ 11:54 PM

    This same issue arises when using hasClass, removeClass and addClass.

    I have suggested a more generic fix for this issue in ticket #841.

  • Fábio M. Costa

    Fábio M. Costa February 6th, 2010 @ 05:29 PM

    The select engine ($$) is fixed but yeah, theres still a bug on hasClass addClass and removeClass. Its easy enough to fix dou... the class should be get like this:

    var class = node.className || node.getAttribute('class');
    

    and setted like this:

    node.className ? node.className = newClassName : node.setAttribute('class', newClassName);
    

    of there are the other code but i hope the issue was understood.

  • Thomas Aylott

    Thomas Aylott February 8th, 2010 @ 01:11 PM

    • State changed from “open” to “resolved”
    • Milestone changed from 2.0 to 1.3.0 rc2

    I'll close the selector-related bug. If we need to, we can have a separate ticket for the addClass bug.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Tags

Referenced by

Pages