Bug 119325 - compareDocumentPosition() reports an attribute and its content as disconnected
Summary: compareDocumentPosition() reports an attribute and its content as disconnected
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-30 23:37 PDT by Chris Dumez
Modified: 2024-03-18 10:15 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2013-07-30 23:37:09 PDT
Node::compareDocumentPosition() reports an attribute and its content as disconnected.
Instead, the attribute should contain and precede its content.

This is causing the following test case to fail:
LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition38.xhtml

I investigated the issue a bit and it seems the problem seems to be that Node::inDocument() returns false for the Text node (content) instead of true.

Note that there is already a workaround in place in Node::compareDocumentPositionInternal() that addresses the same issue for Attribute nodes.

See comment in that method:
// Note that we avoid comparing Attr nodes here, since they return false from inDocument() all the time (which seems like a bug).

It is likely we need to extend the workaround to Text nodes or fix the underlying problem (have inDocument() return correct values for Attr and Text nodes).

Specification:
http://dom.spec.whatwg.org/#dom-node-comparedocumentposition

Corresponding Blink bug:
http://code.google.com/p/chromium/issues/detail?id=264138
Comment 1 Chris Dumez 2013-07-30 23:39:16 PDT
As explained by Adam in http://code.google.com/p/chromium/issues/detail?id=264138#c1, Attr should no longer be a Node according to the latest specification. It should be its own interface [1].

If we followed the spec, the bug would disappear.

[1] http://dom.spec.whatwg.org/#attr
Comment 2 Ahmad Saleem 2024-03-17 15:30:35 PDT
Safari is passing all WPT tests:

https://wpt.fyi/results/dom/nodes/Node-compareDocumentPosition.html?label=master&label=experimental&aligned=

Chris - Do we need to anything here?
Comment 3 Ryosuke Niwa 2024-03-18 10:15:52 PDT
Looks like this bug has been fixed by now.