Re: [Proto-Scripty] How would I get a closer set of siblings?

2010-02-22 Thread Walter Lee Davis
Hmmm. That's not a documented function. I had a look at the source, and I can't see how it works. It accepts a node as its only argument, and it doesn't seem to perform any comparison as it executes. How then would I get it to stick to just the one type of sibling, and how would I get it

Re: [Proto-Scripty] How would I get a closer set of siblings?

2010-02-22 Thread Alex Wallace
I whipped up something that should handle the task, although I'm sure this could be optimized using the nextElementSibling. This version grabs nextSiblings() and then filters them, but the faster way would be to iterate over the `element.nextSibling` and break when it encounters a different tag

Re: [Proto-Scripty] How would I get a closer set of siblings?

2010-02-22 Thread Walter Lee Davis
Thanks very much. I was looking in the wrong place for the functionality I need. You've given me the bones I need to build on. Walter On Feb 22, 2010, at 11:07 AM, Alex Wallace wrote: I whipped up something that should handle the task, although I'm sure this could be optimized using the

Re: [Proto-Scripty] How would I get a closer set of siblings?

2010-02-22 Thread Paul Kim
Hi Walter, if you want to get all similar elements up to but not including the next head, I would use Prototype's Element.nextSiblings() to loop through all elements with the same tagName and break when the tagName is different. Here is a function I created just now that would hopefully do what

Re: [Proto-Scripty] How would I get a closer set of siblings?

2010-02-22 Thread Alex Wallace
Paul, one recommendation: store the results of element.nextSiblings() in a local variable outside of the loop. DOM traversals are pretty slow. Best, Alex On Mon, Feb 22, 2010 at 12:28 PM, Paul Kim kimba...@gmail.com wrote: Hi Walter, if you want to get all similar elements up to but not

Re: [Proto-Scripty] How would I get a closer set of siblings?

2010-02-22 Thread Paul Kim
Hi Alex, thanks for the tip. I've modified the function based on your tip and your example function: function consecutiveSameTagSiblings(element) { var element = $(element); var nextSiblings = element.nextSiblings(); var similarElements = [];