happy-dom 5.3.3 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/.eslintrc.js +2 -2
- package/lib/base64/Base64.d.ts +23 -0
- package/lib/base64/Base64.js +89 -0
- package/lib/base64/Base64.js.map +1 -0
- package/lib/config/ElementTag.d.ts +2 -1
- package/lib/config/ElementTag.js +2 -1
- package/lib/config/ElementTag.js.map +1 -1
- package/lib/config/NonImplemenetedElementClasses.js +0 -1
- package/lib/config/NonImplemenetedElementClasses.js.map +1 -1
- package/lib/dom-implementation/DOMImplementation.d.ts +7 -1
- package/lib/dom-implementation/DOMImplementation.js +10 -2
- package/lib/dom-implementation/DOMImplementation.js.map +1 -1
- package/lib/dom-parser/DOMParser.d.ts +9 -4
- package/lib/dom-parser/DOMParser.js +13 -2
- package/lib/dom-parser/DOMParser.js.map +1 -1
- package/lib/exception/DOMExceptionNameEnum.d.ts +5 -1
- package/lib/exception/DOMExceptionNameEnum.js +4 -0
- package/lib/exception/DOMExceptionNameEnum.js.map +1 -1
- package/lib/fetch/Request.d.ts +8 -0
- package/lib/fetch/Request.js +15 -6
- package/lib/fetch/Request.js.map +1 -1
- package/lib/fetch/Response.d.ts +5 -0
- package/lib/fetch/Response.js +12 -6
- package/lib/fetch/Response.js.map +1 -1
- package/lib/file/FileReader.d.ts +7 -2
- package/lib/file/FileReader.js +9 -3
- package/lib/file/FileReader.js.map +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/location/URL.js +1 -1
- package/lib/location/URL.js.map +1 -1
- package/lib/nodes/comment/Comment.d.ts +1 -1
- package/lib/nodes/document/Document.d.ts +18 -15
- package/lib/nodes/document/Document.js +36 -33
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/document/IDocument.d.ts +7 -0
- package/lib/nodes/document-fragment/DocumentFragment.d.ts +1 -1
- package/lib/nodes/document-type/DocumentType.d.ts +1 -1
- package/lib/nodes/element/DOMRectListFactory.d.ts +23 -0
- package/lib/nodes/element/DOMRectListFactory.js +33 -0
- package/lib/nodes/element/DOMRectListFactory.js.map +1 -0
- package/lib/nodes/element/Element.d.ts +6 -5
- package/lib/nodes/element/Element.js +9 -11
- package/lib/nodes/element/Element.js.map +1 -1
- package/lib/nodes/element/IDOMRectList.d.ts +11 -0
- package/lib/nodes/element/IDOMRectList.js +3 -0
- package/lib/nodes/element/IDOMRectList.js.map +1 -0
- package/lib/nodes/element/IElement.d.ts +5 -4
- package/lib/nodes/html-dialog-element/HTMLDialogElement.d.ts +31 -0
- package/lib/nodes/html-dialog-element/HTMLDialogElement.js +51 -0
- package/lib/nodes/html-dialog-element/HTMLDialogElement.js.map +1 -0
- package/lib/nodes/html-dialog-element/IHTMLDialogElement.d.ts +25 -0
- package/lib/nodes/html-dialog-element/IHTMLDialogElement.js +3 -0
- package/lib/nodes/html-dialog-element/IHTMLDialogElement.js.map +1 -0
- package/lib/nodes/html-template-element/HTMLTemplateElement.d.ts +1 -10
- package/lib/nodes/html-template-element/HTMLTemplateElement.js +2 -15
- package/lib/nodes/html-template-element/HTMLTemplateElement.js.map +1 -1
- package/lib/nodes/node/INode.d.ts +8 -6
- package/lib/nodes/node/Node.d.ts +20 -17
- package/lib/nodes/node/Node.js +19 -15
- package/lib/nodes/node/Node.js.map +1 -1
- package/lib/nodes/node/NodeTypeEnum.d.ts +10 -0
- package/lib/nodes/node/NodeTypeEnum.js +14 -0
- package/lib/nodes/node/NodeTypeEnum.js.map +1 -0
- package/lib/nodes/node/NodeUtility.d.ts +59 -0
- package/lib/nodes/node/NodeUtility.js +123 -0
- package/lib/nodes/node/NodeUtility.js.map +1 -0
- package/lib/nodes/text/IText.d.ts +9 -0
- package/lib/nodes/text/Text.d.ts +10 -1
- package/lib/nodes/text/Text.js +24 -0
- package/lib/nodes/text/Text.js.map +1 -1
- package/lib/range/IRangeBoundaryPoint.d.ts +8 -0
- package/lib/range/IRangeBoundaryPoint.js +3 -0
- package/lib/range/IRangeBoundaryPoint.js.map +1 -0
- package/lib/range/Range.d.ts +249 -0
- package/lib/range/Range.js +820 -0
- package/lib/range/Range.js.map +1 -0
- package/lib/range/RangeHowEnum.d.ts +7 -0
- package/lib/range/RangeHowEnum.js +11 -0
- package/lib/range/RangeHowEnum.js.map +1 -0
- package/lib/range/RangeUtility.d.ts +46 -0
- package/lib/range/RangeUtility.js +92 -0
- package/lib/range/RangeUtility.js.map +1 -0
- package/lib/selection/Selection.d.ts +167 -44
- package/lib/selection/Selection.js +369 -58
- package/lib/selection/Selection.js.map +1 -1
- package/lib/selection/SelectionDirectionEnum.d.ts +6 -0
- package/lib/selection/SelectionDirectionEnum.js +10 -0
- package/lib/selection/SelectionDirectionEnum.js.map +1 -0
- package/lib/window/IWindow.d.ts +22 -0
- package/lib/window/Window.d.ts +25 -9
- package/lib/window/Window.js +85 -35
- package/lib/window/Window.js.map +1 -1
- package/lib/xml-parser/XMLParser.d.ts +2 -2
- package/lib/xml-parser/XMLParser.js +5 -3
- package/lib/xml-parser/XMLParser.js.map +1 -1
- package/lib/xml-serializer/XMLSerializer.js +4 -1
- package/lib/xml-serializer/XMLSerializer.js.map +1 -1
- package/package.json +2 -2
- package/src/base64/Base64.ts +97 -0
- package/src/config/ElementTag.ts +2 -1
- package/src/config/NonImplemenetedElementClasses.ts +0 -1
- package/src/dom-implementation/DOMImplementation.ts +13 -2
- package/src/dom-parser/DOMParser.ts +20 -7
- package/src/exception/DOMExceptionNameEnum.ts +5 -1
- package/src/fetch/Request.ts +16 -6
- package/src/fetch/Response.ts +13 -6
- package/src/file/FileReader.ts +14 -4
- package/src/index.ts +7 -1
- package/src/location/URL.ts +1 -1
- package/src/nodes/document/Document.ts +47 -39
- package/src/nodes/document/IDocument.ts +8 -0
- package/src/nodes/element/DOMRectListFactory.ts +33 -0
- package/src/nodes/element/Element.ts +10 -11
- package/src/nodes/element/IDOMRectList.ts +11 -0
- package/src/nodes/element/IElement.ts +5 -4
- package/src/nodes/html-dialog-element/HTMLDialogElement.ts +47 -0
- package/src/nodes/html-dialog-element/IHTMLDialogElement.ts +29 -0
- package/src/nodes/html-template-element/HTMLTemplateElement.ts +3 -21
- package/src/nodes/node/INode.ts +8 -6
- package/src/nodes/node/Node.ts +24 -19
- package/src/nodes/node/NodeTypeEnum.ts +11 -0
- package/src/nodes/node/NodeUtility.ts +139 -0
- package/src/nodes/text/IText.ts +10 -0
- package/src/nodes/text/Text.ts +33 -0
- package/src/range/IRangeBoundaryPoint.ts +9 -0
- package/src/range/Range.ts +1057 -0
- package/src/range/RangeHowEnum.ts +8 -0
- package/src/range/RangeUtility.ts +114 -0
- package/src/selection/Selection.ts +444 -60
- package/src/selection/SelectionDirectionEnum.ts +7 -0
- package/src/window/IWindow.ts +24 -0
- package/src/window/Window.ts +104 -32
- package/src/xml-parser/XMLParser.ts +15 -7
- package/src/xml-serializer/XMLSerializer.ts +6 -1
- package/lib/nodes/element/Range.d.ts +0 -167
- package/lib/nodes/element/Range.js +0 -215
- package/lib/nodes/element/Range.js.map +0 -1
- package/lib/window/WindowBase64.d.ts +0 -19
- package/lib/window/WindowBase64.js +0 -88
- package/lib/window/WindowBase64.js.map +0 -1
- package/src/nodes/element/Range.ts +0 -237
- package/src/window/WindowBase64.ts +0 -95
@@ -0,0 +1,123 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const NodeTypeEnum_1 = __importDefault(require("./NodeTypeEnum"));
|
7
|
+
/**
|
8
|
+
* Node utility.
|
9
|
+
*/
|
10
|
+
class NodeUtility {
|
11
|
+
/**
|
12
|
+
* Returns boolean indicating if nodeB is an inclusive ancestor of nodeA.
|
13
|
+
*
|
14
|
+
* Based on:
|
15
|
+
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/helpers/node.js
|
16
|
+
*
|
17
|
+
* @see https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor
|
18
|
+
* @param ancestorNode Ancestor node.
|
19
|
+
* @param referenceNode Reference node.
|
20
|
+
* @returns "true" if following.
|
21
|
+
*/
|
22
|
+
static isInclusiveAncestor(ancestorNode, referenceNode) {
|
23
|
+
let parent = referenceNode;
|
24
|
+
while (parent) {
|
25
|
+
if (ancestorNode === parent) {
|
26
|
+
return true;
|
27
|
+
}
|
28
|
+
parent = parent.parentNode;
|
29
|
+
}
|
30
|
+
return false;
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Returns boolean indicating if nodeB is following nodeA in the document tree.
|
34
|
+
*
|
35
|
+
* Based on:
|
36
|
+
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/helpers/node.js
|
37
|
+
*
|
38
|
+
* @see https://dom.spec.whatwg.org/#concept-tree-following
|
39
|
+
* @param nodeA Node A.
|
40
|
+
* @param nodeB Node B.
|
41
|
+
* @returns "true" if following.
|
42
|
+
*/
|
43
|
+
static isFollowing(nodeA, nodeB) {
|
44
|
+
if (nodeA === nodeB) {
|
45
|
+
return false;
|
46
|
+
}
|
47
|
+
let current = nodeB;
|
48
|
+
while (current) {
|
49
|
+
current = this.following(current);
|
50
|
+
if (current === nodeA) {
|
51
|
+
return true;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return false;
|
55
|
+
}
|
56
|
+
/**
|
57
|
+
* Node length.
|
58
|
+
*
|
59
|
+
* Based on:
|
60
|
+
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/helpers/node.js
|
61
|
+
*
|
62
|
+
* @see https://dom.spec.whatwg.org/#concept-node-length
|
63
|
+
* @param node Node.
|
64
|
+
* @returns Node length.
|
65
|
+
*/
|
66
|
+
static getNodeLength(node) {
|
67
|
+
switch (node.nodeType) {
|
68
|
+
case NodeTypeEnum_1.default.documentTypeNode:
|
69
|
+
return 0;
|
70
|
+
case NodeTypeEnum_1.default.textNode:
|
71
|
+
case NodeTypeEnum_1.default.processingInstructionNode:
|
72
|
+
case NodeTypeEnum_1.default.commentNode:
|
73
|
+
return node.data.length;
|
74
|
+
default:
|
75
|
+
return node.childNodes.length;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
/**
|
79
|
+
* Returns boolean indicating if nodeB is following nodeA in the document tree.
|
80
|
+
*
|
81
|
+
* Based on:
|
82
|
+
* https://github.com/jsdom/js-symbol-tree/blob/master/lib/SymbolTree.js#L220
|
83
|
+
*
|
84
|
+
* @param node Node.
|
85
|
+
* @param [root] Root.
|
86
|
+
* @returns Following node.
|
87
|
+
*/
|
88
|
+
static following(node, root) {
|
89
|
+
const firstChild = node.firstChild;
|
90
|
+
if (firstChild) {
|
91
|
+
return firstChild;
|
92
|
+
}
|
93
|
+
let current = node;
|
94
|
+
while (current) {
|
95
|
+
if (current === root) {
|
96
|
+
return null;
|
97
|
+
}
|
98
|
+
const nextSibling = current.nextSibling;
|
99
|
+
if (nextSibling) {
|
100
|
+
return nextSibling;
|
101
|
+
}
|
102
|
+
current = current.parentNode;
|
103
|
+
}
|
104
|
+
return null;
|
105
|
+
}
|
106
|
+
/**
|
107
|
+
* Returns the next sibling or parents sibling.
|
108
|
+
*
|
109
|
+
* @param node Node.
|
110
|
+
* @returns Next decentant node.
|
111
|
+
*/
|
112
|
+
static nextDecendantNode(node) {
|
113
|
+
while (node && !node.nextSibling) {
|
114
|
+
node = node.parentNode;
|
115
|
+
}
|
116
|
+
if (!node) {
|
117
|
+
return null;
|
118
|
+
}
|
119
|
+
return node.nextSibling;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
exports.default = NodeUtility;
|
123
|
+
//# sourceMappingURL=NodeUtility.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"NodeUtility.js","sourceRoot":"","sources":["../../../src/nodes/node/NodeUtility.ts"],"names":[],"mappings":";;;;;AAGA,kEAA0C;AAE1C;;GAEG;AACH,MAAqB,WAAW;IAC/B;;;;;;;;;;OAUG;IACI,MAAM,CAAC,mBAAmB,CAAC,YAAmB,EAAE,aAAoB;QAC1E,IAAI,MAAM,GAAU,aAAa,CAAC;QAClC,OAAO,MAAM,EAAE;YACd,IAAI,YAAY,KAAK,MAAM,EAAE;gBAC5B,OAAO,IAAI,CAAC;aACZ;YACD,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;SAC3B;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,WAAW,CAAC,KAAY,EAAE,KAAY;QACnD,IAAI,KAAK,KAAK,KAAK,EAAE;YACpB,OAAO,KAAK,CAAC;SACb;QAED,IAAI,OAAO,GAAU,KAAK,CAAC;QAE3B,OAAO,OAAO,EAAE;YACf,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAElC,IAAI,OAAO,KAAK,KAAK,EAAE;gBACtB,OAAO,IAAI,CAAC;aACZ;SACD;QAED,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,aAAa,CAAC,IAAW;QACtC,QAAQ,IAAI,CAAC,QAAQ,EAAE;YACtB,KAAK,sBAAY,CAAC,gBAAgB;gBACjC,OAAO,CAAC,CAAC;YAEV,KAAK,sBAAY,CAAC,QAAQ,CAAC;YAC3B,KAAK,sBAAY,CAAC,yBAAyB,CAAC;YAC5C,KAAK,sBAAY,CAAC,WAAW;gBAC5B,OAA0B,IAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YAE7C;gBACC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;SAC/B;IACF,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,SAAS,CAAC,IAAW,EAAE,IAAY;QAChD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAEnC,IAAI,UAAU,EAAE;YACf,OAAO,UAAU,CAAC;SAClB;QAED,IAAI,OAAO,GAAG,IAAI,CAAC;QAEnB,OAAO,OAAO,EAAE;YACf,IAAI,OAAO,KAAK,IAAI,EAAE;gBACrB,OAAO,IAAI,CAAC;aACZ;YAED,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;YAExC,IAAI,WAAW,EAAE;gBAChB,OAAO,WAAW,CAAC;aACnB;YAED,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;SAC7B;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,iBAAiB,CAAC,IAAW;QAC1C,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACjC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;SACvB;QAED,IAAI,CAAC,IAAI,EAAE;YACV,OAAO,IAAI,CAAC;SACZ;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;CACD;AAlID,8BAkIC"}
|
@@ -1,5 +1,14 @@
|
|
1
1
|
import ICharacterData from '../character-data/ICharacterData';
|
2
2
|
export default interface IText extends ICharacterData {
|
3
|
+
/**
|
4
|
+
* Breaks the Text node into two nodes at the specified offset, keeping both nodes in the tree as siblings.
|
5
|
+
*
|
6
|
+
* @see https://dom.spec.whatwg.org/#dom-text-splittext
|
7
|
+
* @see https://dom.spec.whatwg.org/#dom-text-splittext
|
8
|
+
* @param offset Offset.
|
9
|
+
* @returns New text node.
|
10
|
+
*/
|
11
|
+
splitText(offset: number): IText;
|
3
12
|
/**
|
4
13
|
* Clones a node.
|
5
14
|
*
|
package/lib/nodes/text/Text.d.ts
CHANGED
@@ -4,13 +4,22 @@ import IText from './IText';
|
|
4
4
|
* Text node.
|
5
5
|
*/
|
6
6
|
export default class Text extends CharacterData implements IText {
|
7
|
-
readonly nodeType =
|
7
|
+
readonly nodeType = NodeTypeEnum.textNode;
|
8
8
|
/**
|
9
9
|
* Node name.
|
10
10
|
*
|
11
11
|
* @returns Node name.
|
12
12
|
*/
|
13
13
|
get nodeName(): string;
|
14
|
+
/**
|
15
|
+
* Breaks the Text node into two nodes at the specified offset, keeping both nodes in the tree as siblings.
|
16
|
+
*
|
17
|
+
* @see https://dom.spec.whatwg.org/#dom-text-splittext
|
18
|
+
* @see https://dom.spec.whatwg.org/#dom-text-splittext
|
19
|
+
* @param offset Offset.
|
20
|
+
* @returns New text node.
|
21
|
+
*/
|
22
|
+
splitText(offset: number): IText;
|
14
23
|
/**
|
15
24
|
* Converts to string.
|
16
25
|
*
|
package/lib/nodes/text/Text.js
CHANGED
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const Node_1 = __importDefault(require("../node/Node"));
|
7
7
|
const CharacterData_1 = __importDefault(require("../character-data/CharacterData"));
|
8
|
+
const DOMException_1 = __importDefault(require("../../exception/DOMException"));
|
9
|
+
const DOMExceptionNameEnum_1 = __importDefault(require("../../exception/DOMExceptionNameEnum"));
|
8
10
|
/**
|
9
11
|
* Text node.
|
10
12
|
*/
|
@@ -21,6 +23,28 @@ class Text extends CharacterData_1.default {
|
|
21
23
|
get nodeName() {
|
22
24
|
return '#text';
|
23
25
|
}
|
26
|
+
/**
|
27
|
+
* Breaks the Text node into two nodes at the specified offset, keeping both nodes in the tree as siblings.
|
28
|
+
*
|
29
|
+
* @see https://dom.spec.whatwg.org/#dom-text-splittext
|
30
|
+
* @see https://dom.spec.whatwg.org/#dom-text-splittext
|
31
|
+
* @param offset Offset.
|
32
|
+
* @returns New text node.
|
33
|
+
*/
|
34
|
+
splitText(offset) {
|
35
|
+
const length = this._data.length;
|
36
|
+
if (offset > length) {
|
37
|
+
new DOMException_1.default('The index is not in the allowed range.', DOMExceptionNameEnum_1.default.indexSizeError);
|
38
|
+
}
|
39
|
+
const count = length - offset;
|
40
|
+
const newData = this.substringData(offset, count);
|
41
|
+
const newNode = this.ownerDocument.createTextNode(newData);
|
42
|
+
if (this.parentNode !== null) {
|
43
|
+
this.parentNode.insertBefore(newNode, this.nextSibling);
|
44
|
+
}
|
45
|
+
this.replaceData(offset, count, '');
|
46
|
+
return newNode;
|
47
|
+
}
|
24
48
|
/**
|
25
49
|
* Converts to string.
|
26
50
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../../../src/nodes/text/Text.ts"],"names":[],"mappings":";;;;;AAAA,wDAAgC;AAChC,oFAA4D;
|
1
|
+
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../../../src/nodes/text/Text.ts"],"names":[],"mappings":";;;;;AAAA,wDAAgC;AAChC,oFAA4D;AAE5D,gFAAwD;AACxD,gGAAwE;AAExE;;GAEG;AACH,MAAqB,IAAK,SAAQ,uBAAa;IAA/C;;QACiB,aAAQ,GAAG,cAAI,CAAC,SAAS,CAAC;IA6D3C,CAAC;IA3DA;;;;OAIG;IACH,IAAW,QAAQ;QAClB,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;;;;;;OAOG;IACI,SAAS,CAAC,MAAc;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAEjC,IAAI,MAAM,GAAG,MAAM,EAAE;YACpB,IAAI,sBAAY,CACf,wCAAwC,EACxC,8BAAoB,CAAC,cAAc,CACnC,CAAC;SACF;QAED,MAAM,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,OAAO,GAAU,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAElE,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE;YAC7B,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;SACxD;QAED,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAEpC,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,QAAQ;QACd,OAAO,eAAe,CAAC;IACxB,CAAC;IAED;;;;;;OAMG;IACI,SAAS,CAAC,IAAI,GAAG,KAAK;QAC5B,OAAa,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACD;AA9DD,uBA8DC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"IRangeBoundaryPoint.js","sourceRoot":"","sources":["../../src/range/IRangeBoundaryPoint.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,249 @@
|
|
1
|
+
import INode from '../nodes/node/INode';
|
2
|
+
import IDocument from '../nodes/document/IDocument';
|
3
|
+
import IDocumentFragment from '../nodes/document-fragment/IDocumentFragment';
|
4
|
+
import DOMRect from '../nodes/element/DOMRect';
|
5
|
+
import RangeHowEnum from './RangeHowEnum';
|
6
|
+
import IDOMRectList from '../nodes/element/IDOMRectList';
|
7
|
+
import IRangeBoundaryPoint from './IRangeBoundaryPoint';
|
8
|
+
/**
|
9
|
+
* Range.
|
10
|
+
*
|
11
|
+
* Based on logic from:
|
12
|
+
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/range/Range-impl.js
|
13
|
+
*
|
14
|
+
* Reference:
|
15
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Range.
|
16
|
+
*/
|
17
|
+
export default class Range {
|
18
|
+
static _ownerDocument: IDocument;
|
19
|
+
static readonly END_TO_END: number;
|
20
|
+
static readonly END_TO_START: number;
|
21
|
+
static readonly START_TO_END: number;
|
22
|
+
static readonly START_TO_START: number;
|
23
|
+
readonly END_TO_END: number;
|
24
|
+
readonly END_TO_START: number;
|
25
|
+
readonly START_TO_END: number;
|
26
|
+
readonly START_TO_START: number;
|
27
|
+
readonly _ownerDocument: IDocument;
|
28
|
+
_start: IRangeBoundaryPoint;
|
29
|
+
_end: IRangeBoundaryPoint;
|
30
|
+
/**
|
31
|
+
* Constructor.
|
32
|
+
*/
|
33
|
+
constructor();
|
34
|
+
/**
|
35
|
+
* Returns start container.
|
36
|
+
*
|
37
|
+
* @see https://dom.spec.whatwg.org/#dom-range-startcontainer
|
38
|
+
* @returns Start container.
|
39
|
+
*/
|
40
|
+
get startContainer(): INode;
|
41
|
+
/**
|
42
|
+
* Returns end container.
|
43
|
+
*
|
44
|
+
* @see https://dom.spec.whatwg.org/#dom-range-endcontainer
|
45
|
+
* @returns End container.
|
46
|
+
*/
|
47
|
+
get endContainer(): INode;
|
48
|
+
/**
|
49
|
+
* Returns start offset.
|
50
|
+
*
|
51
|
+
* @see https://dom.spec.whatwg.org/#dom-range-startoffset
|
52
|
+
* @returns Start offset.
|
53
|
+
*/
|
54
|
+
get startOffset(): number;
|
55
|
+
/**
|
56
|
+
* Returns end offset.
|
57
|
+
*
|
58
|
+
* @see https://dom.spec.whatwg.org/#dom-range-endoffset
|
59
|
+
* @returns End offset.
|
60
|
+
*/
|
61
|
+
get endOffset(): number;
|
62
|
+
/**
|
63
|
+
* Returns a boolean value indicating whether the range's start and end points are at the same position.
|
64
|
+
*
|
65
|
+
* @see https://dom.spec.whatwg.org/#dom-range-collapsed
|
66
|
+
* @returns Collapsed.
|
67
|
+
*/
|
68
|
+
get collapsed(): boolean;
|
69
|
+
/**
|
70
|
+
* Returns the deepest Node that contains the startContainer and endContainer nodes.
|
71
|
+
*
|
72
|
+
* @see https://dom.spec.whatwg.org/#dom-range-commonancestorcontainer
|
73
|
+
* @returns Node.
|
74
|
+
*/
|
75
|
+
get commonAncestorContainer(): INode;
|
76
|
+
/**
|
77
|
+
* Returns -1, 0, or 1 depending on whether the referenceNode is before, the same as, or after the Range.
|
78
|
+
*
|
79
|
+
* @see https://dom.spec.whatwg.org/#dom-range-collapse
|
80
|
+
* @param toStart A boolean value: true collapses the Range to its start, false to its end. If omitted, it defaults to false.
|
81
|
+
*/
|
82
|
+
collapse(toStart?: boolean): void;
|
83
|
+
/**
|
84
|
+
* Compares the boundary points of the Range with those of another range.
|
85
|
+
*
|
86
|
+
* @see https://dom.spec.whatwg.org/#dom-range-compareboundarypoints
|
87
|
+
* @param how How.
|
88
|
+
* @param sourceRange Range.
|
89
|
+
* @returns A number, -1, 0, or 1, indicating whether the corresponding boundary-point of the Range is respectively before, equal to, or after the corresponding boundary-point of sourceRange.
|
90
|
+
*/
|
91
|
+
compareBoundaryPoints(how: RangeHowEnum, sourceRange: Range): number;
|
92
|
+
/**
|
93
|
+
* Returns -1, 0, or 1 depending on whether the referenceNode is before, the same as, or after the Range.
|
94
|
+
*
|
95
|
+
* @see https://dom.spec.whatwg.org/#dom-range-comparepoint
|
96
|
+
* @param node Reference node.
|
97
|
+
* @param offset Offset.
|
98
|
+
* @returns -1,0, or 1.
|
99
|
+
*/
|
100
|
+
comparePoint(node: INode, offset: any): number;
|
101
|
+
/**
|
102
|
+
* Returns a DocumentFragment copying the objects of type Node included in the Range.
|
103
|
+
*
|
104
|
+
* @see https://dom.spec.whatwg.org/#concept-range-clone
|
105
|
+
* @returns Document fragment.
|
106
|
+
*/
|
107
|
+
cloneContents(): IDocumentFragment;
|
108
|
+
/**
|
109
|
+
* Returns a Range object with boundary points identical to the cloned Range.
|
110
|
+
*
|
111
|
+
* @see https://dom.spec.whatwg.org/#dom-range-clonerange
|
112
|
+
* @returns Range.
|
113
|
+
*/
|
114
|
+
cloneRange(): Range;
|
115
|
+
/**
|
116
|
+
* 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.
|
117
|
+
*
|
118
|
+
* @see https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm
|
119
|
+
* @param tagString Tag string.
|
120
|
+
* @returns Document fragment.
|
121
|
+
*/
|
122
|
+
createContextualFragment(tagString: string): IDocumentFragment;
|
123
|
+
/**
|
124
|
+
* Removes the contents of the Range from the Document.
|
125
|
+
*
|
126
|
+
* @see https://dom.spec.whatwg.org/#dom-range-deletecontents
|
127
|
+
*/
|
128
|
+
deleteContents(): void;
|
129
|
+
/**
|
130
|
+
* Does nothing. It used to disable the Range object and enable the browser to release associated resources. The method has been kept for compatibility.
|
131
|
+
*
|
132
|
+
* @see https://dom.spec.whatwg.org/#dom-range-detach
|
133
|
+
*/
|
134
|
+
detach(): void;
|
135
|
+
/**
|
136
|
+
* Moves contents of the Range from the document tree into a DocumentFragment.
|
137
|
+
*
|
138
|
+
* @see https://dom.spec.whatwg.org/#dom-range-extractcontents
|
139
|
+
* @returns Document fragment.
|
140
|
+
*/
|
141
|
+
extractContents(): IDocumentFragment;
|
142
|
+
/**
|
143
|
+
* Returns a DOMRect object that bounds the contents of the range; this is a rectangle enclosing the union of the bounding rectangles for all the elements in the range.
|
144
|
+
*
|
145
|
+
* @returns DOMRect object.
|
146
|
+
*/
|
147
|
+
getBoundingClientRect(): DOMRect;
|
148
|
+
/**
|
149
|
+
* The Range.getClientRects() method returns a list of DOMRect objects representing the area of the screen occupied by the range. This is created by aggregating the results of calls to Element.getClientRects() for all the elements in the range.
|
150
|
+
*
|
151
|
+
* @returns DOMRect objects.
|
152
|
+
*/
|
153
|
+
getClientRects(): IDOMRectList<DOMRect>;
|
154
|
+
/**
|
155
|
+
* Returns a boolean indicating whether the given point is in the Range.
|
156
|
+
*
|
157
|
+
* @see https://dom.spec.whatwg.org/#dom-range-ispointinrange
|
158
|
+
* @param node Reference node.
|
159
|
+
* @param offset Offset.
|
160
|
+
* @returns "true" if in range.
|
161
|
+
*/
|
162
|
+
isPointInRange(node: INode, offset?: number): boolean;
|
163
|
+
/**
|
164
|
+
* Inserts a node at the start of the Range.
|
165
|
+
*
|
166
|
+
* @see https://dom.spec.whatwg.org/#concept-range-insert
|
167
|
+
* @param newNode New node.
|
168
|
+
*/
|
169
|
+
insertNode(newNode: INode): void;
|
170
|
+
/**
|
171
|
+
* Returns a boolean indicating whether the given Node intersects the Range.
|
172
|
+
*
|
173
|
+
* @see https://dom.spec.whatwg.org/#dom-range-intersectsnode
|
174
|
+
* @param node Reference node.
|
175
|
+
* @returns "true" if it intersects.
|
176
|
+
*/
|
177
|
+
intersectsNode(node: INode): boolean;
|
178
|
+
/**
|
179
|
+
* Sets the Range to contain the Node and its contents.
|
180
|
+
*
|
181
|
+
* @see https://dom.spec.whatwg.org/#concept-range-select
|
182
|
+
* @param node Reference node.
|
183
|
+
*/
|
184
|
+
selectNode(node: INode): void;
|
185
|
+
/**
|
186
|
+
* Sets the Range to contain the contents of a Node.
|
187
|
+
*
|
188
|
+
* @see https://dom.spec.whatwg.org/#dom-range-selectnodecontents
|
189
|
+
* @param node Reference node.
|
190
|
+
*/
|
191
|
+
selectNodeContents(node: INode): void;
|
192
|
+
/**
|
193
|
+
* Sets the end position of a Range to be located at the given offset into the specified node x.
|
194
|
+
*
|
195
|
+
* @see https://dom.spec.whatwg.org/#dom-range-setend
|
196
|
+
* @param node End node.
|
197
|
+
* @param offset End offset.
|
198
|
+
*/
|
199
|
+
setEnd(node: INode, offset?: number): void;
|
200
|
+
/**
|
201
|
+
* Sets the start position of a Range.
|
202
|
+
*
|
203
|
+
* @see https://dom.spec.whatwg.org/#dom-range-setstart
|
204
|
+
* @param node Start node.
|
205
|
+
* @param offset Start offset.
|
206
|
+
*/
|
207
|
+
setStart(node: INode, offset?: number): void;
|
208
|
+
/**
|
209
|
+
* Sets the end position of a Range relative to another Node.
|
210
|
+
*
|
211
|
+
* @see https://dom.spec.whatwg.org/#dom-range-setendafter
|
212
|
+
* @param node Reference node.
|
213
|
+
*/
|
214
|
+
setEndAfter(node: INode): void;
|
215
|
+
/**
|
216
|
+
* Sets the end position of a Range relative to another Node.
|
217
|
+
*
|
218
|
+
* @see https://dom.spec.whatwg.org/#dom-range-setendbefore
|
219
|
+
* @param node Reference node.
|
220
|
+
*/
|
221
|
+
setEndBefore(node: INode): void;
|
222
|
+
/**
|
223
|
+
* Sets the start position of a Range relative to a Node.
|
224
|
+
*
|
225
|
+
* @see https://dom.spec.whatwg.org/#dom-range-setstartafter
|
226
|
+
* @param node Reference node.
|
227
|
+
*/
|
228
|
+
setStartAfter(node: INode): void;
|
229
|
+
/**
|
230
|
+
* Sets the start position of a Range relative to another Node.
|
231
|
+
*
|
232
|
+
* @see https://dom.spec.whatwg.org/#dom-range-setstartbefore
|
233
|
+
* @param node Reference node.
|
234
|
+
*/
|
235
|
+
setStartBefore(node: INode): void;
|
236
|
+
/**
|
237
|
+
* Moves content of the Range into a new node, placing the new node at the start of the specified range.
|
238
|
+
*
|
239
|
+
* @see https://dom.spec.whatwg.org/#dom-range-surroundcontents
|
240
|
+
* @param newParent New parent.
|
241
|
+
*/
|
242
|
+
surroundContents(newParent: INode): void;
|
243
|
+
/**
|
244
|
+
* Returns the text of the Range.
|
245
|
+
*
|
246
|
+
* @see https://dom.spec.whatwg.org/#dom-range-stringifier
|
247
|
+
*/
|
248
|
+
toString(): string;
|
249
|
+
}
|