Yes, Element.getStyle(el, prop) is different to el.getStyle(prop); because the later doesn't need the Element to be extended with $ (in IE and Safari 2).

$ and $$ add the mootools methods to the elements for browsers that dont support the element prototype, this process is quite fast, so you shouldn't case about it in most situations. However, pseudo selectors are run quite frequently. $$('*:hidden") on a page with 100 elements would run the function 100 times, so in that case we don't want all elements to be extended.

We call these functions generics and they are added to all Natives automatically, so there's for example also a String.toUpperCase('foo'); instead of 'foo'.toUpperCase(). The first argument is bound to the method as the "this" and further arguments are used as arguments. These functions can be useful to map an array etc.: ['mootools', 'cow', 'milk'].map(String.toUpperCase); // ['MOOTOOLS, 'COW', 'MILK']

ciao,
Jan

On Jan 15, 2009, at 13:38, cheeaun wrote:


On Jan 15, 7:25 pm, Jan Kassens <[email protected]> wrote:
you could create a custom pseudo selector:

Selectors.Pseudo.hidden = function(){
     return Element.getStyle(this, 'display') == 'none';

};

One question, is that different than this?:

Selectors.Pseudo.hidden = function(){
 return this.getStyle('display') == 'none';
};

--
Jan - MooTools comitter
twitter/blog: http://kassens.net

Reply via email to