index: Fix attached elements

Passing `document` into the private `selector` function throws a
`TypeError`.  This will happen when an (attached) element is provided
whose parents don't have IDs.

Closes #4.
Merge pull request #6 from stephenmathieson/fix/attached-elements

index: Fix attached elements