[DOM] Fix Fragment compareDocumentPosition for documentElement and empty portals (#37163)