// if source is a method
$$(css).source() -> equiv
$$(css)[0].source() -> equiv
$$(css).first().source() -> equiv
you could always cache it
var source = $$(css).source();
// an array of sources
$$(css).invoke('source'); // OR
$$(css).each($$.source); //notice static $$.source method
$$(css)._each($$.source); // faster than all of them :P
if source is a property
//no soup for $$().<method>
$$(css)[0].source
$$(css).first().source
$$(css).pluck('source');
//get height of first matched item (equivs)
$$(css).first().getHeight(),
$$(css)[0].getHeight(), and
$$(css).getHeight() are equivs.
// array of heights (equivs)
$$(css).invoke('getHeight');
$$(css).each($$.getHeight);
$$(css)._each($$.getHeight);
//setters
$$(css).update(...); //sets all matched items
$$(css).setStyle(...) //sets all matched items
$$(css).addClassName(...) // does it to all matched items
$$(css).show().observer('click', ...); // shows all matches and
attached an onclick observer to all of them.
// get element by id
$(id).hide();
$(id).source() or $(id).source (whichever we decide)
$(id).source()._prototypeWrapperID //the id that the cache looks at
$(id).source()._prototypeWrapperID -> [2]
// its an array with a number in it
because it wont transfer when you clone the node, this is how
its done in the current event system when element._prototypeEventID is
set.
We mod Class.create to allow the "initialize" method to return a value
so then:
Prototype.NodeWrapper = Class.create({
initialize: function(...) {
// ...
if (Prototype.isWrapper(element)) { // some check for wrapper
return element;
}
// ... resolve element from ID or whatnot
var cacheID = (element._prototypeWrapperID || [null])[0];
if (cacheID) {
return Prototype.NodeWrapper.cache[cacheID];
}
// set source, however that is decided on.
this._source = element;
}, // ...
})
The reason we name it "source" instead of "element" or "dom"
is so we can always know what the source of a wrapper is without
having to guess if its an
Element wrapper to check for "element" if its an event wrapper to
check for .event.
we would know its always .source.
- JDD
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---