The compareDocumentPosition check was extraneous - indexOf works in all the other...