NEW 249114
Remove non-standard Range.compareNode()
https://bugs.webkit.org/show_bug.cgi?id=249114
Summary Remove non-standard Range.compareNode()
Ahmad Saleem
Reported 2022-12-11 15:37:20 PST
Hi Team, While going through Blink commit's, I came across another non-standard, which is now only present in Webkit from quick Github search: e.g., https://github.com/WebKit/WebKit/blob/bf6ec0b71883ada1ee6d8d0c66a8ea7e421c5e27/Source/WebCore/dom/Range.idl#L68 & https://github.com/WebKit/WebKit/blob/bf6ec0b71883ada1ee6d8d0c66a8ea7e421c5e27/Source/WebCore/dom/Range.cpp#L187 Blink Commit - https://chromium.googlesource.com/chromium/blink/+/9cec195ebb459d3ebdc7ef91a6336047c07ae5b7 Intent to Remove Thread - https://groups.google.com/a/chromium.org/g/blink-dev/c/5dNJaHFNFGM Some background: Added in 2006 - https://trac.webkit.org/changeset/16302/webkit MDN - https://developer.mozilla.org/en-US/docs/Web/API/range/compareNode (Removed from Firefox in 1.9) Web-Spec - https://dom.spec.whatwg.org/#interface-range Just wanted to raise bug to track it for discussion or for future tracking. Thanks!
Attachments
Ryosuke Niwa
Comment 1 2022-12-11 22:37:28 PST
A quick GitHub search finds quite a few entries: https://github.com/search?q=Range.compareNode+language%3AJavaScript&type=code&l=JavaScript I don't think it's safe to remove this API.
Radar WebKit Bug Importer
Comment 2 2022-12-18 15:38:16 PST
Karl Dubost
Comment 3 2024-12-25 22:28:32 PST
https://searchfox.org/wubkat/rev/36d40c7dfd972e688c9c0febea6821825a85d6ac/Source/WebCore/dom/Range.cpp#207-239 ```cpp ExceptionOr<Range::CompareResults> Range::compareNode(Node& node) const { // FIXME: This deprecated function should be removed. // We originally added it for interoperability with Firefox. // Recent versions of Firefox have removed it. // http://developer.mozilla.org/en/docs/DOM:range.compareNode // This method returns 0, 1, 2, or 3 based on if the node is before, after, // before and after(surrounds), or inside the range, respectively. if (!node.isConnected() || &node.document() != m_ownerDocument.ptr()) { // Match historical Firefox behavior. return NODE_BEFORE; } auto nodeRange = makeRangeSelectingNode(node); if (!nodeRange) { // Match historical Firefox behavior. return Exception { ExceptionCode::NotFoundError }; } auto startOrdering = treeOrder(nodeRange->start, makeBoundaryPoint(m_start)); auto endOrdering = treeOrder(nodeRange->end, makeBoundaryPoint(m_end)); if (is_gteq(startOrdering) && is_lteq(endOrdering)) return NODE_INSIDE; if (is_lteq(startOrdering) && is_gteq(endOrdering)) return NODE_BEFORE_AND_AFTER; if (is_lteq(startOrdering)) return NODE_BEFORE; if (is_gteq(endOrdering)) return NODE_AFTER; return Exception { ExceptionCode::WrongDocumentError }; } ```
Karl Dubost
Comment 4 2024-12-25 22:41:50 PST
I see 84 instances on GitHub https://github.com/search?q=Range.compareNode+language%3AJavaScript&type=code&l=JavaScript BUT but most of them have this pattern: ``` range.compareNode(editableHost) !== range.NODE_BEFORE_AND_AFTER ``` which comes from a DEPRECATED library https://github.com/Fixxpunkt/editable.js/ They link editable.js ⛔ [DEPRECATED] Active at https://github.com/Fixxpunkt/sto/ Which is itself dead. The fork was from https://github.com/search?q=repo%3AlivingdocsIO%2Feditable.js%20compareNode&type=code which contains no compareNode hit. Another one which has been archived https://github.com/wymeditor/wymeditor
Ahmad Saleem
Comment 5 2024-12-26 12:34:43 PST
Note You need to log in before you can comment on or make changes to this bug.