On Sep 8, 3:13 pm, "
jip...@gmail.com" <
jip...@gmail.com> wrote:
> I place a comment on the bug trtacker to point Kangax solution. It is
> indeed simple and effective.
>
>
http://prototype.lighthouseapp.com/projects/8886-prototype/tickets/24...
While it's simple and effective, the problem is inability of
`Selector` class to work with complex or multiple selectors.
`adjacent` supports passing any number of selectors to match elements
against. `new Selector` can't handle more than one and that one can
only be a simple one : )
There's a way to use grep but its O(n^2) complexity makes it ugly : /
adjacent2: function(element) {
element = $(element), expressions = $A(arguments).slice(1);
return Element.siblings(element).grep({
match: function(element) {
return expressions.any(function(expr) {
return element.match(expr);
});
}
});
}
This would obviously work nicely if Selector constructor was able to
accept complex selectors.
Any other ideas?
--
kangax