Add compareDocumentPosition (fixes #1794)