Prototype 1.6.1-rc2
Posted by Nucc
PrototypeJS developers has announced 1.6.1-rc2 on March 27. The new release provides full IE8 compatibility, DOM functions have extended with clone method, you can store key value pairs binding to a node, and moreover better performance in bind() and DOM explorer functions.
Clone method: The javascript engines provide cloneNode() method for cloning an element of a DOM, but there were problems in IE, because IE copied only the node’s initialized version, every latter modifications (like attached event handling) lost. This prototype version calls cloneNode() method, so be careful with previous IE versions.
-
clone: function(element, deep) {
-
if (!(element = $(element))) return;
-
var clone = element.cloneNode(deep);
-
clone._prototypeUID = void 0;
-
if (deep) {
-
var descendants = Element.select(clone, ‘*’),
-
i = descendants.length;
-
while (i–) {
-
descendants[i]._prototypeUID = void 0;
-
}
-
}
-
return Element.extend(clone);
-
}
Storage: The storage engine provides capability to store key value pairs binding to a node. It’s very useful when some variables are in connection with a specified DOM element. If the element was dropped, you should remove all variables, which would become unusable. If we didn’t do this, after a while our site would eat the user’s memory, or have to clean the trashes by us.
Usage:
-
// Creating new storage
-
var storage = Element.getStorage( $(‘foobar’) );
-
-
// Attaching {foo: "bar"} to node foobar
-
$(‘foobar’).store("foo", "bar");
-
-
// Get the value
-
alert(storage.get("foo"));
-
-
// Remove node
-
$(‘foobar’).remove();
The only problem is IE8 doesn’t release the memory in my tests. I’ve tried to store 50000 strings to observe memory statistic. IE8 reserved 2 megabytes, and dropping the node didn’t realize in memory state. In FF 3.0.7 memory release works fine (it’s not strange).
New events: Events mouseenter and mouseleave are the same as mouseover and mouseout, new namings are introduced because Microsoft prefers the first pair.