MooTools upgrade: From 1.1 to 1.2

About

Well this is just a list of things that should be changed when porting a script from MooTools 1.1 to 1.2… It's quite possible that I forgot some… hence why this page is a wiki! Just add to it or correct it as you see fit.

Core

Differences

$pick

In 1.1
Pick takes 2 arguments one object to test and one default.
In 1.2
Pick can take any number of arguments to test, the last one being the default

Example:

// in 1.1
function say(msg){
    alert($pick(msg, 'no meessage supplied'));
}
 
// in 1.2
function say(infoMessage, errorMessage){
    alert($pick(errorMessage, infoMessage, 'There was no message supplied.'));
}

New in 1.2

Removed in 1.2

$native
removed in 1.2

Browser

Completely new in Mootools 1.2, it replaces the old window class. Here are some 1.1 to 1.2 equivalences:

1.1 1.2
window.ie Browser.Engine.trident
window.ie6 Browser.Engine.trident4
windoe.ie7 Browser.Engine.trident5
window.gecko Browser.Engine.gecko
window.webkit Browser.Engine.webkit
window.opera Browser.Engine.presto

The full doc for the Browser Hash can be seen here: http://docs.mootools.net/Core/Browser

Native

Array

Differences

Todo

New in 1.2

Removed from 1.2

forEach
use Array.each instead
Array.copy
use $A instead
Array.remove
use Array.erase instead
$each
use Array.each instead

Function

New in 1.2

Removed from 1.2

Function.bindAsEventListener
removed, every addEvent callback now has an event

Number

No changes

String

Differences

Todo

New in 1.2

String.stripScripts
String.substitute

Hash

Hash is now a native in 1.2. It used to be a plugin in 1.1

Differences

1.1 1.2
Hash.keys Hash.getKeys
Hash.values Hash.getValues
Hash.merge Hash.combine
Hash.hasKey Hash.has

New in 1.2

Hash.hasValue
Hash.keyOf
Hash.include
Hash.map
Hash.filter
Hash.every
Hash.some
Hash.getClean
Hash.toQueryString

Event

In MooTools 1.2, Event has been split so that the Element related event methods are in Element.Event and the rest (more global event methods) are in the native Event class.

Methods that are now in the Native Event class:

  • Event.stop
  • Event.stopPropagation
  • Event.preventDefault

Methods that are (still) in Element.Event:

  • Element.addEvent
  • Element.removeEvent
  • Element.addEvents
  • Element.removeEvents
  • Element.fireEvent
  • Element.cloneEvents
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License