Dunno if it's faster per se, but el.siblings().match('.className') looks nice :)
:Dan
But, y'know, too bad it doesn't work. Sorry about that. You could try
chaining findAll after siblings, but that kinda what you're trying to
avoid, huh?
:Dan
Yep, I'm not sure what I was smoking exactly, but I think it had some
jQuery in it :)
By way of penance, some extra credit work. Louis, If you find yourself
needing this functionality a lot, you could always augment the
behavior of siblings using Function.wrap:
Element.addMethods({
siblings: Element.siblings.wrap(function(proceed, element, selector) {
var sibs = proceed.call(this, element);
return selector ?
sibs.grep(selector instanceof Selector ?
selector :
new Selector(selector)) :
sibs;
})
});
:Dan
It makes a ton of sense, since before I even started work on that last
snippet, I was wondering why that sort of functionality wasn't already
in Prototype. That ancestors, siblings, et al, inherit from the same
method would seem to make it exceptionally low-hanging fruit. Any idea
on whether your patch will make it into the next release?
:Dan