Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox 18 breaks mootools 1.2.5 selector engine

Working jsfiddle example here: http://jsfiddle.net/CfJyd/

The problem only occurs in Firefox 18 that I know of.

The following html:

<div class="test">Test Div</div>
<div class="testIgnore">This should stay the same</div>

With this js:

window.addEvent('domready',function() {
    $$('.test').set('html','Only Test should update');
});

Results in this output:

Only Test should update
Only Test should update

Upgrading to Mootools 1.4.5 isn't an option at the moment because of lots of plugins that use 1.2.5, can anybody point me in the right direction on getting a fix?

like image 947
Adriaan Nel Avatar asked Jan 10 '13 21:01

Adriaan Nel


1 Answers

I've found the answer here: https://groups.google.com/forum/#!msg/mootools-users/W7MHwTFHYQ4/B4HcR951XQYJ

Add the following code anywhere in javascript - I added it just above mootools, and it works perfectly:

String.prototype.contains = function(string, separator){
    return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : String(this).indexOf(string) > -1;
};
like image 180
Adriaan Nel Avatar answered Oct 11 '22 13:10

Adriaan Nel