...
> I forked prototype, and started working on NodeWrapper/NodeListWrapper
> - http://github.com/kangax/prototype/tree/master/src/element.js
> Accompanying tests are there as well (although the test suite is far
> from being complete).
>
> --
> kangax
Exciting to see in code! What about adding caching instances and maybe even
using a double-duty constructor instead of Class.create? See what I mean
below.
- Ken Snyder
Prototype.Element = function(element) {
if (this instanceof Prototype.Element) {
// constructor
element.__prototypeWrapper = this;
this.raw = element;
} else {
// "getInstance" function
// allow element to be string, dom node, or Prototype.Element instance
element = (typeof element === 'string' ?
document.getElementById(element) : element);
if (element instanceof Prototype.Element) {
return element;
}
if (element && element.__prototypeWrapper) {
return element.__prototypeWrapper;
} else {
return new Prototype.Element(element)
}
}
};
$W = Prototype.Element;
var myDiv = document.getElementById('someDiv');
var myWrappedDiv = $W('someDiv');
myWrappedDiv === $W(myDiv); // true
myWrappedDiv === $W(myWrappedDiv); // true
// although $W() is called 3 times, only one instance is created
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---