1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:57:35 +00:00

LibWeb: Add implementation of Node.compareDocumentPosition()

While looking into getting Duck Duck Go loading further in the
Browser, I noticed that it was complaining about the missing
method Node.compareDocumentPosition.

This change implements as much of the DOM spec as possible
with the current implementation of the DOM to date. The
implementation is validated by new tests in the Node.js.
This commit is contained in:
Brian Gianforcaro 2021-04-10 17:21:22 -07:00 committed by Andreas Kling
parent 0f8932d7ab
commit 988c23fff0
4 changed files with 69 additions and 0 deletions

View file

@ -32,4 +32,12 @@ interface Node : EventTarget {
const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
const unsigned short NOTATION_NODE = 12;
unsigned short compareDocumentPosition(Node? otherNode);
// Node.compareDocumentPosition() constants
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 1;
const unsigned short DOCUMENT_POSITION_PRECEDING = 2;
const unsigned short DOCUMENT_POSITION_FOLLOWING = 4;
const unsigned short DOCUMENT_POSITION_CONTAINS = 8;
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 16;
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
};