MooTools 1.3

image
image
The long-awaited rilis MooTools 1.3. Will tell a little about the changes in the framework, in its "environment". Between versions 1.2 and 1.3 is quite a lot of differences, but all in good time.

The first thing to say is that there is a build of version 1.3 which is 100% compatible with 1.2, can be updated.

Slick

So, about the differences. The most delicious thing in the new version is a new css selector engine Slick. It is completely independent of MooTools, can be used separately. He "scarabi" supports all imaginable selectors/pseudo selectors, but if you and this will seem a little, do not worry, there is always the opportunity to create a new one.
Examples of usage outside of MooTools:
the
Slick.search(document, "div > p.moo:not(.foo)"); // returns a collection (array) of items, even if the sample were only one, if you did not choose a single element, returns null. The first  parameter  is the context of search, the second selector.
Slick.find(document, "div > p.moo:not(.foo)"); // almost the same, but now returns only one, the first matching the selector element
Slick.match(node, "p.moo"); // checks for compliance with the specified node selector
Slick.contains(node, node2); // checks whether node2 in node

Inside the MooTools same selectors as usual.

And now simply:
the
    the
  • Pure javascript
  • the
  • 50% Faster than the old one
  • the
  • Supports any selector which you can think of
  • the
  • Flexible, allows you to create your own pseudo-selectors
  • the
  • Supports search in XML

API Changes

Core

the
    the
  • $methods now in the past:
  • the
  • $chk(value) => (value != null)
  • the
  • $A(item) => Array.from(item)
  • the
  • $splat => Array.from
  • the
  • $clear => have to use the native clearTimeout or clearInterval
  • the
  • $defined = > (value != null)
  • the
  • $each => Array.each / Object.each depending on the context
  • the
  • $empty => removed, it is necessary to use function(){}
  • the
  • $extend(source, extended) => Object.append(source, extended)
  • the
  • $merge({}, a, b) => Object.merge({}, a, b)
  • the
  • $mixin(a, b) => Object.merge(a, b)
  • the
  • $lambda => Function.from
  • the
  • $random => Number.random
  • the
  • $time => Date.now
  • the
  • $type => typeOf with a modification for empty objects now returns the string “null”
  • the
  • $unlink => Array.clone / Object.clone
  • the
  • $arguments => deleted
  • the
  • $pick => Array.pick or [a, b, c].pick()
  • the
  • $exec => Browser.exec

And
the
    the
  • Native now referred to as Type
  • the
  • Array.type / String.type / Number.type / etc. => Type.isArray / Type.isString / Type.isNumber / etc.
  • the
  • Hash and $H moved to MooTools More

Browser detection

the
    the
  • Engine detection => user-agent detection.
  • the
  • Browser.Engine => deleted
  • the
  • Browser.Engine.trident => Browser.ie
  • the
  • Browser.Engine.gecko => Browser.firefox
  • the
  • Browser.Engine.webkit => Browser.safari or Browser.chrome
  • the
  • Browser.Engine.presto => Browser.opera
  • the
  • Browser.Platform.ipod => Browser.Platform.ios

Array

the
    the
  • Array.extend => Array.append

Function

the
    the
  • myFn.bind(this, [arg1, arg2, arg3]) => myFn.bind(this, arg1, arg2, arg3) or myFn.pass([arg1, arg2, arg3], this)
  • the
  • $try => Function.attempt
  • the
  • myFn.run(args, bind) = > myFn.apply(bind, Array.from(args));
  • the
  • myFn.create => use .pass .bind .delay .periodical
  • the
  • myFn.bindWithEvent => obsolete

Element

the
    the
  • element.injectInside, .injectBefore, .injectAfter, etc => element.inject(context, where);
  • the
  • element.grabTop,... => element.grab(context, where)
  • the
  • element.hasChild(item) => element.contains(item) &&
  • the
  • item != element
  • the
  • Selectors.Pseudo => Slick.definePseudo(name, fn)
  • the
  • Element.get => no longer supported by the second parameter (this is used for the animation element.get(‘tween’, options) is now element.set(‘tween’, options).get(‘tween’))

Using Slick to create new elements and easier:
the
new Element("input", {"id": "someID", "class": "someClass1", "disabled": true}); // Was
new Element("input#someID.someClass1[disabled=true]"); // was

what's New

the
    the
  • Type.from (Array.from String.from, Function.from, etc) => type conversion
  • the
  • Fx => unified timer for all effects

environment

the
    the
  • MooTools Test Runner => testing now takes place automatically not only in every browser but on the server
  • the
  • Packager => a new tool for the collection of MooTools suit your needs.
  • Packager

    Packager was designed for project management. It works as follows: you create the code at the beginning of each file make a special comment specifying the name, author, dependencies, etc., create a configuration package file (project), which specifies the name, description, list of participating in the Assembly files, etc., packager works from the terminal:
    the
    $ packager register /path/to/project
    $ packager build ProjectName/* > myproject.js
    

    When building external dependencies are taken into account. Under external I mean dependencies on other projects, which are also registered in the Packager. A very handy thing, use for their projects for six months.

    Summary

    Overall, it was rewritten about a third of the code. Also a lot of changes in MooTools More, for example there is support for pseudo-selectors for events such as:
    the
    element.addEvent('click:once', function(){}); // after the click handler will be automatically deleted
    element.addEvent('click:relay(.some-selector)', function(){}); // and here we have a delegation
    element.addEvent('keydown:keys(ctrl+s)', function(){}); // I think here everything is clear
    

    The next big release — MooTools 2 (now for sure).
    Repository:
    MooTools Core
    MooTools More
    Slick
    Packager
Article based on information from habrahabr.ru

Comments

Popular posts from this blog

Powershell and Cyrillic in the console (updated)

Active/Passive PostgreSQL Cluster, using Pacemaker, Corosync

Automatic deployment ElasticBeanstalk using Bitbucket Pipelines