It looks like when insertBefore() or insertAfter() has the same element as the origin and the destination, the element is deleted. Is my understanding correct?
$('#foo').insertBefore($('#foo'))
Is this a feature? If so, what other gotchas are there with these functions?
It actually seems that it is a known bug (not a feature), although there may be an incoming fix (1.9 release).
From the bug comments: