Unexpected selector results with FireFox beta

1,235 views
Skip to first unread message

Ralph Slooten

unread,
Dec 10, 2012, 6:50:14 PM12/10/12
to mootool...@googlegroups.com
Hi all,

Please forgive me if this issue has been noted before (I couldn't find it), however I noticed some strange behaviour resulting from Firefox beta and the $$ selector (using class names) using MooTools 1.2.5. I do realise that 1.2.5 is old, however we have several sites using it, and this issue seems to be something that could affect several of them. I was hoping to find the answer/solution before having to start rewriting stuff :)

Problem:
It would seem that something like $$('div.find') also finds partial matches for elements eg: <div class="finds">, or <div class="donotfindme"> when using 1.2.5 and the beta version of FireFox.

I have an example on jsfiddle.net/wZsax/ - all other browsers seem fine and find just the first element, however FF beta finds both.

I realise that this does not happen in later versions of MooTools, nor with the stable version of Firefox (v17), however should the beta become stable (assuming no change to the JS engine affecting this), then this could become a bigger problem.

Could anyone point out whether this is a bug in MooTools 1.2.5, and if so whether there could be a fix at the core-level?

Many thanks & kind regards,
Ralph

Arian Stolwijk

unread,
Dec 10, 2012, 6:55:23 PM12/10/12
to mootool...@googlegroups.com
I think this relates to https://github.com/mootools/mootools-core/issues/2402

Could you add this somewhere, probably before adding MooTools to the page.

String.prototype.contains = function(string, separator){
return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : String(this).indexOf(string) > -1;
};

We probably need to fix this as a 1.2.6.

Ralph Slooten

unread,
Dec 10, 2012, 7:45:59 PM12/10/12
to mootool...@googlegroups.com
Hi Arian,

Thanks for your quick response! Yes, this fixes the problem, even if it's added after the MooTools core (but before the script itself): http://jsfiddle.net/wZsax/1/

Thanks again,
Ralph

Arian Stolwijk

unread,
Jan 14, 2013, 7:45:50 PM1/14/13
to mootool...@googlegroups.com
Even a simpler solution is:

Before you load MooTools, do:

delete String.prototype.contains;


Arian Stolwijk

unread,
Jan 14, 2013, 7:46:12 PM1/14/13
to mootool...@googlegroups.com

Arian Stolwijk

unread,
Feb 19, 2013, 12:14:44 PM2/19/13
to mootool...@googlegroups.com

Ralph Slooten

unread,
Feb 20, 2013, 12:58:23 PM2/20/13
to mootool...@googlegroups.com

Excellent! Thanks for the follow-up.

Regards,
Ralph

--
 
---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mootools-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages