StaticRange-impl.js
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"use strict";
const DOMException = require("domexception/webidl2js-wrapper");
const NODE_TYPE = require("../node-type");
const AbstractRangeImpl = require("./AbstractRange-impl").implementation;
// https://dom.spec.whatwg.org/#staticrange
class StaticRangeImpl extends AbstractRangeImpl {
// https://dom.spec.whatwg.org/#dom-staticrange-staticrange
constructor(globalObject, args) {
const { startContainer, startOffset, endContainer, endOffset } = args[0];
if (
startContainer.nodeType === NODE_TYPE.DOCUMENT_TYPE_NODE ||
startContainer.nodeType === NODE_TYPE.ATTRIBUTE_NODE ||
endContainer.nodeType === NODE_TYPE.DOCUMENT_TYPE_NODE ||
endContainer.nodeType === NODE_TYPE.ATTRIBUTE_NODE
) {
throw DOMException.create(globalObject, ["The supplied node is incorrect.", "InvalidNodeTypeError"]);
}
super(globalObject, [], {
start: {
node: startContainer,
offset: startOffset
},
end: {
node: endContainer,
offset: endOffset
}
});
}
}
module.exports = {
implementation: StaticRangeImpl
};