added test case and bug fix for (next|previous)(Elements|Siblings) methods
This commit is contained in:
@@ -202,23 +202,26 @@ fun Node.nextSiblings() : Iterator<Node> = NextSiblingIterator(this)
|
||||
class NextSiblingIterator(var node: Node) : AbstractIterator<Node>() {
|
||||
|
||||
override fun computeNext(): Unit {
|
||||
val next = node.getNextSibling()
|
||||
if (next != null) {
|
||||
setNext(next)
|
||||
val nextValue = node.getNextSibling()
|
||||
if (nextValue != null) {
|
||||
setNext(nextValue)
|
||||
node = nextValue
|
||||
} else {
|
||||
done()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns an [[Iterator]] over the next siblings of this node */
|
||||
fun Node.previousSiblings() : Iterator<Node> = PreviousSiblingIterator(this)
|
||||
|
||||
class PreviousSiblingIterator(var node: Node) : AbstractIterator<Node>() {
|
||||
|
||||
override fun computeNext(): Unit {
|
||||
val next = node.getPreviousSibling()
|
||||
if (next != null) {
|
||||
setNext(next)
|
||||
val nextValue = node.getPreviousSibling()
|
||||
if (nextValue != null) {
|
||||
setNext(nextValue)
|
||||
node = nextValue
|
||||
} else {
|
||||
done()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user