Eq now returns an empty Selector when an invalid index is given

This commit is contained in:
tnt
2014-02-28 21:54:48 +01:00
parent e273eed13e
commit 48de68c2b7
2 changed files with 22 additions and 2 deletions
+5
View File
@@ -24,6 +24,11 @@ func (this *Selection) Eq(index int) *Selection {
if index < 0 {
index += len(this.Nodes)
}
if index >= len(this.Nodes) || index < 0 {
return newEmptySelection(this.document)
}
return this.Slice(index, index+1)
}