From d9653ffdea55ec5b0f6c3077d4b81fe839ae9e6d Mon Sep 17 00:00:00 2001 From: David Ortner Date: Tue, 24 May 2022 23:56:19 +0200 Subject: [PATCH] #450@trivial: Starts adding support for Range. --- packages/happy-dom/src/range/Range.ts | 41 +++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/packages/happy-dom/src/range/Range.ts b/packages/happy-dom/src/range/Range.ts index 294f75129..8f5c4c151 100644 --- a/packages/happy-dom/src/range/Range.ts +++ b/packages/happy-dom/src/range/Range.ts @@ -1,5 +1,6 @@ import INode from '../nodes/node/INode'; import IDocument from '../nodes/document/IDocument'; +import IDocumentFragment from '../nodes/document-fragment/IDocumentFragment'; /** * Range. @@ -42,12 +43,46 @@ export default class Range { } /** - * Collapses the current selection. + * Returns -1, 0, or 1 depending on whether the referenceNode is before, the same as, or after the Range. * - * @param _toStart To start. + * @param _referenceNode Reference node. + * @param [_offset=0] Offset. + * @returns -1,0, or 1. */ - public collapse(_toStart?: boolean): void { + public comparePoint(_referenceNode: INode, _offset = 0): number { // TODO: Implement + return 0; + } + + /** + * Returns a DocumentFragment copying the objects of type Node included in the Range. + * + * @returns Document fragment. + */ + public cloneContents(): IDocumentFragment { + // TODO: Implement + return null; + } + + /** + * Returns a Range object with boundary points identical to the cloned Range. + * + * @returns Range. + */ + public cloneRange(): Range { + // TODO: Implement + return null; + } + + /** + * Returns a DocumentFragment by invoking the HTML fragment parsing algorithm or the XML fragment parsing algorithm with the start of the range (the parent of the selected node) as the context node. The HTML fragment parsing algorithm is used if the range belongs to a Document whose HTMLness bit is set. In the HTML case, if the context node would be html, for historical reasons the fragment parsing algorithm is invoked with body as the context instead. + * + * @param _tagString Tag string. + * @returns Document fragment. + */ + public createContextualFragment(_tagString: string): IDocumentFragment { + // TODO: Implement + return null; } /**