Skip to content

Commit

Permalink
#450@trivial: Starts adding support for Range.
Browse files Browse the repository at this point in the history
  • Loading branch information
capricorn86 committed May 24, 2022
1 parent 57e07b9 commit d9653ff
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions 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.
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit d9653ff

Please sign in to comment.