Is $ (document.body) and document.body the same? Garbage cleaning and binding in the classroom? - MooTools 1.3

I create a MooTools class, and I have this in my initialization function:

this.css = null;

window.addEvent('domready', function(){

    this.document = $(document);
    this.body = $(document.body);
    this.head = $(document.head);

}.bind(this));

Ok, now for the questions ... Should I declare this.css = null or any other empty variable in init:

this.css = null; // Maybe this.css = '' - empty string?

The rest of the discussion is about the window and the document ... Should I put it in $ () or not, because it works in both directions, so I just want to know which path is preferred? So to summarize:

window.addEvent() // or should I use $(window).addEvent()
this.document = $(document) // or this.document = document
this.body = $(document.body) // or this.body = document.body

I saved these values ​​in an object to avoid multiple DOM requests, is this normal? Or would it be better to call $ (selector) / $$ (selector) each time?

... ... .bind() .bind(this.myDiv) , : this.setStyle(...); this.myDiv.setStyle(...)

(function(){
  this.setStyle('overflow-y', 'visible');
 }.bind(this.body)).delay(100);

(function(){
  this.body.setStyle('overflow-y', 'visible');
 }.bind(this)).delay(100);

, ... ( , MooTools ). , MT:

myElement.destroy();

: , . .

, ? ? .destroy()? , , IE script ( ? , , ?).

+5
1

pff, .

, . this.css = null... , "" : typecast; undefined; /; null .

/ mootools Options mixin. , . , Object.merge({ var: val}, useroptions); , .

, iirc, , $(document.body), , document.body , $() Element IE ( , , , $them). , $ UID . $(document) $(window) - "" , . , IE, $(something) "-". document.getElementById("foo").method() - $("foo"); , document.getElementById("foo").method() - IE.

window.addEvent(); // is fine. 
document.body.adopt(new Element("div")); // not fine in IE.
new Element("div").inject(document.body); // fine.

:

$(document.body).adopt(new Element("div")); // fine.
document.body.adopt(new Element("span")); // now fine, after first $.

. ie8: http://www.jsfiddle.net/AePzD/1/ - , . , document.body.methods() .

http://www.jsfiddle.net/AePzD/2/ - , ( $) webkit/mozilla, . $( "foo" ), . : $, , .

, . , . , . , , sizzle slick, , ( , FPS).

, , .

, , BIND:

(function(){
      this.setStyle('background', 'blue');
 }).delay(100, $("foo"));

. ,

(function(){
      this.element.setStyle('background', 'blue');
      this.someMethod();
 }).delay(100, this));

. , mootools GC. .destroy - , imo. - DOM, element.dispose(). DOM, .destroy() - . \o/

IE ​​... . , , , dynatrace, . ... , js, , (, ) , , , ajax ( , - ...). - ...

+6
source

All Articles