Skip to content

Update from 1.2 to 1.3

lorenzos edited this page Jul 7, 2011 · 2 revisions

MooTools Core 1.3 is backwards compatible with all the documented features of MooTools Core 1.2 through an inbuilt compatibility layer. This guide helps you avoid minor problems while updating. If you want to drop the compatibility layer see the upgrade guide: Upgrade from 1.2 to 1.3


MooTools has provided an implementation of this method for years, however the new ECMAScript 5 specification describes a different behavior. If you use the compatibility layer, the 1.2 version of "bind" will be used. If you drop the compatibility layer, the implementation equals to that of the ECMAScript 5 specification and it uses the native implementation of a browser, if available (Chrome 6, Firefox 4, …).

The difference in both versions is that the specification takes any amount of arguments and the MooTools version only takes an array as second argument.


myFn.bind(this, arg1, arg2, arg3); // ES5 Spec
myFn.bind(this, arguments); // MooTools Core 1.2

To avoid possible problems once you drop the compatibility layer you can use the following script to automatically convert all occurrences of bind with arguments to the "pass"-method that we provide in MooTools.

Replace bind

To ensure compatibility with the plugins you release, you should not use bind with arguments (ie, just use .bind(thisArg)) and resort to using Function.prototype.pass. This method works like our old implementation of "bind" with reversed argument order.


myFn.bind(this, arguments); // DON'T do this anymore
myFn.pass(arguments, this); // YES

Element.get / Element.set compatibility

In the past, these two methods were able to take any amount of arguments. This was undocumented but used by some people. To bring back the old 1.2 behavior you can use the following script: Element.get/Element.set.

Please use the above script at your own risk. In order to update from 1.2 to 1.3, you should replace any occurrences of the Element.get method with options like this:

myElement.get('tween', options); // WRONG
myElement.set('tween', options).get('tween'); // YES, INDEED.


The get/post/put/delete methods used to accept the URL as argument rather than the data. Our documentation however only described to send data via those methods, so this behavior was fixed in 1.3. Instead of passing the URL via the .get/.post/.put/.delete methods, pass the URL as option when you create the Request instance.

JSON (since 1.3.1)

JSON.decode can throw errors when the secure argument is set to true. This is the same behavior as the native JSON.parse. Also this native function will be used if it's available (in all modern browsers). Previously just null was returned.

JSON.decode('no valid json string', true); // `null` in < 1.3.1

try { // 1.3.1
    JSON.decode('no valid json string', true);
} catch(e){
    console.log('failed to decode JSON');
// or a little shorter and easier to update
JSON.decode.attempt(['no valid json string', true]);
You can’t perform that action at this time.