Good point - I adapted the code (poorly!) from `_findPos()`. Easy fix is `offsetTarget.length`.

Agree if there is no visible sibling we'll end up with an error, although I think that `findPos()` would have already generated an error in that instance anyway so the code probably wouldn't execute.

```
while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
	obj = obj[isRTL ? "previousSibling" : "nextSibling"];
}

position = $(obj).offset();
return [position.left, position.top];
```


Copying/adapting the code from `findPos()` is probably a poor approach anyway - seems to highlight an underlying problem a bit. I wonder if we're better to create a new variable a little further up the scope for the element we use to position against. Then there just needs to be a single function which can search right, left, and then up the DOM until it finds a visible element.