@gjsify/dom-elements 0.3.13 → 0.3.14
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.
- package/lib/esm/_virtual/_rolldown/runtime.js +18 -0
- package/lib/esm/attr.js +37 -30
- package/lib/esm/character-data.js +61 -54
- package/lib/esm/comment.js +26 -19
- package/lib/esm/document-fragment.js +116 -109
- package/lib/esm/document.js +75 -81
- package/lib/esm/dom-matrix.js +158 -123
- package/lib/esm/dom-token-list.js +114 -108
- package/lib/esm/element.js +244 -246
- package/lib/esm/font-face.js +94 -89
- package/lib/esm/gst-time.js +17 -6
- package/lib/esm/html-canvas-element.js +82 -75
- package/lib/esm/html-element.js +424 -424
- package/lib/esm/html-image-element.js +226 -225
- package/lib/esm/html-media-element.js +117 -114
- package/lib/esm/html-video-element.js +110 -108
- package/lib/esm/image.js +27 -21
- package/lib/esm/index.js +13 -45
- package/lib/esm/intersection-observer.js +22 -18
- package/lib/esm/location-stub.js +25 -23
- package/lib/esm/match-media.js +18 -19
- package/lib/esm/mutation-observer.js +18 -13
- package/lib/esm/named-node-map.js +121 -121
- package/lib/esm/namespace-uri.js +9 -8
- package/lib/esm/node-list.js +39 -33
- package/lib/esm/node-type.js +13 -12
- package/lib/esm/node.js +241 -246
- package/lib/esm/property-symbol.js +36 -30
- package/lib/esm/register/canvas.js +11 -7
- package/lib/esm/register/document.js +19 -18
- package/lib/esm/register/font-face.js +10 -6
- package/lib/esm/register/helpers.js +14 -12
- package/lib/esm/register/image.js +4 -0
- package/lib/esm/register/location.js +4 -0
- package/lib/esm/register/match-media.js +4 -0
- package/lib/esm/register/navigator.js +4 -1
- package/lib/esm/register/observers.js +5 -1
- package/lib/esm/resize-observer.js +15 -12
- package/lib/esm/text.js +56 -49
- package/lib/esm/types/index.js +3 -3
- package/package.json +11 -11
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!no_symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll };
|
package/lib/esm/attr.js
CHANGED
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
1
|
+
import { name, ownerElement, value } from "./property-symbol.js";
|
|
2
|
+
|
|
3
|
+
//#region src/attr.ts
|
|
4
|
+
/**
|
|
5
|
+
* Represents a DOM attribute.
|
|
6
|
+
*
|
|
7
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/Attr
|
|
8
|
+
*/
|
|
9
|
+
var Attr = class {
|
|
10
|
+
constructor(name$1, value$1, namespaceURI = null, prefix = null, ownerElement$1 = null) {
|
|
11
|
+
this.specified = true;
|
|
12
|
+
this[name] = name$1;
|
|
13
|
+
this[value] = value$1;
|
|
14
|
+
this[ownerElement] = ownerElement$1;
|
|
15
|
+
this.namespaceURI = namespaceURI;
|
|
16
|
+
this.prefix = prefix;
|
|
17
|
+
const colonIndex = name$1.indexOf(":");
|
|
18
|
+
this.localName = colonIndex !== -1 ? name$1.slice(colonIndex + 1) : name$1;
|
|
19
|
+
}
|
|
20
|
+
get name() {
|
|
21
|
+
return this[name];
|
|
22
|
+
}
|
|
23
|
+
get value() {
|
|
24
|
+
return this[value];
|
|
25
|
+
}
|
|
26
|
+
set value(value$2) {
|
|
27
|
+
this[value] = value$2;
|
|
28
|
+
}
|
|
29
|
+
get ownerElement() {
|
|
30
|
+
return this[ownerElement];
|
|
31
|
+
}
|
|
32
|
+
get [(name, value, ownerElement, Symbol.toStringTag)]() {
|
|
33
|
+
return "Attr";
|
|
34
|
+
}
|
|
31
35
|
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Attr };
|
|
@@ -1,56 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeType } from "./property-symbol.js";
|
|
2
2
|
import { NodeType } from "./node-type.js";
|
|
3
|
-
import
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
3
|
+
import { Node } from "./node.js";
|
|
4
|
+
|
|
5
|
+
//#region src/character-data.ts
|
|
6
|
+
/**
|
|
7
|
+
* CharacterData base class for Text and Comment nodes.
|
|
8
|
+
*
|
|
9
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/CharacterData
|
|
10
|
+
*/
|
|
11
|
+
var CharacterData = class extends Node {
|
|
12
|
+
constructor(data = "") {
|
|
13
|
+
super();
|
|
14
|
+
this[nodeType] = NodeType.TEXT_NODE;
|
|
15
|
+
this._data = data;
|
|
16
|
+
}
|
|
17
|
+
get data() {
|
|
18
|
+
return this._data;
|
|
19
|
+
}
|
|
20
|
+
set data(value) {
|
|
21
|
+
this._data = value;
|
|
22
|
+
}
|
|
23
|
+
get textContent() {
|
|
24
|
+
return this._data;
|
|
25
|
+
}
|
|
26
|
+
set textContent(value) {
|
|
27
|
+
this._data = value;
|
|
28
|
+
}
|
|
29
|
+
get nodeValue() {
|
|
30
|
+
return this._data;
|
|
31
|
+
}
|
|
32
|
+
set nodeValue(value) {
|
|
33
|
+
this._data = value;
|
|
34
|
+
}
|
|
35
|
+
get length() {
|
|
36
|
+
return this._data.length;
|
|
37
|
+
}
|
|
38
|
+
appendData(data) {
|
|
39
|
+
this._data += data;
|
|
40
|
+
}
|
|
41
|
+
deleteData(offset, count) {
|
|
42
|
+
this._data = this._data.substring(0, offset) + this._data.substring(offset + count);
|
|
43
|
+
}
|
|
44
|
+
insertData(offset, data) {
|
|
45
|
+
this._data = this._data.substring(0, offset) + data + this._data.substring(offset);
|
|
46
|
+
}
|
|
47
|
+
replaceData(offset, count, data) {
|
|
48
|
+
this._data = this._data.substring(0, offset) + data + this._data.substring(offset + count);
|
|
49
|
+
}
|
|
50
|
+
substringData(offset, count) {
|
|
51
|
+
return this._data.substring(offset, offset + count);
|
|
52
|
+
}
|
|
53
|
+
cloneNode(_deep = false) {
|
|
54
|
+
const clone = new this.constructor(this._data);
|
|
55
|
+
return clone;
|
|
56
|
+
}
|
|
57
|
+
get [Symbol.toStringTag]() {
|
|
58
|
+
return "CharacterData";
|
|
59
|
+
}
|
|
56
60
|
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { CharacterData };
|
package/lib/esm/comment.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeType } from "./property-symbol.js";
|
|
2
2
|
import { NodeType } from "./node-type.js";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
import { CharacterData } from "./character-data.js";
|
|
4
|
+
|
|
5
|
+
//#region src/comment.ts
|
|
6
|
+
/**
|
|
7
|
+
* Comment node.
|
|
8
|
+
*
|
|
9
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/Comment
|
|
10
|
+
*/
|
|
11
|
+
var Comment = class Comment extends CharacterData {
|
|
12
|
+
constructor(data = "") {
|
|
13
|
+
super(data);
|
|
14
|
+
this[nodeType] = NodeType.COMMENT_NODE;
|
|
15
|
+
}
|
|
16
|
+
get nodeName() {
|
|
17
|
+
return "#comment";
|
|
18
|
+
}
|
|
19
|
+
cloneNode(_deep = false) {
|
|
20
|
+
return new Comment(this.data);
|
|
21
|
+
}
|
|
22
|
+
get [Symbol.toStringTag]() {
|
|
23
|
+
return "Comment";
|
|
24
|
+
}
|
|
21
25
|
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Comment };
|
|
@@ -1,112 +1,119 @@
|
|
|
1
|
+
import { elementChildren, nodeType } from "./property-symbol.js";
|
|
2
|
+
import { NodeType } from "./node-type.js";
|
|
1
3
|
import { Node } from "./node.js";
|
|
2
4
|
import { Text } from "./text.js";
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
5
|
+
|
|
6
|
+
//#region src/document-fragment.ts
|
|
7
|
+
/**
|
|
8
|
+
* DocumentFragment.
|
|
9
|
+
*
|
|
10
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
|
|
11
|
+
*/
|
|
12
|
+
var DocumentFragment = class DocumentFragment extends Node {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this[nodeType] = NodeType.DOCUMENT_FRAGMENT_NODE;
|
|
16
|
+
}
|
|
17
|
+
get nodeName() {
|
|
18
|
+
return "#document-fragment";
|
|
19
|
+
}
|
|
20
|
+
/** Element children only (excludes text/comment nodes) */
|
|
21
|
+
get children() {
|
|
22
|
+
return this[elementChildren];
|
|
23
|
+
}
|
|
24
|
+
get childElementCount() {
|
|
25
|
+
return this[elementChildren].length;
|
|
26
|
+
}
|
|
27
|
+
get firstElementChild() {
|
|
28
|
+
return this[elementChildren][0] ?? null;
|
|
29
|
+
}
|
|
30
|
+
get lastElementChild() {
|
|
31
|
+
const children = this[elementChildren];
|
|
32
|
+
return children[children.length - 1] ?? null;
|
|
33
|
+
}
|
|
34
|
+
get textContent() {
|
|
35
|
+
let text = "";
|
|
36
|
+
for (const child of this.childNodes) {
|
|
37
|
+
if (child.textContent !== null) {
|
|
38
|
+
text += child.textContent;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return text;
|
|
42
|
+
}
|
|
43
|
+
set textContent(value) {
|
|
44
|
+
while (this.firstChild) {
|
|
45
|
+
this.removeChild(this.firstChild);
|
|
46
|
+
}
|
|
47
|
+
if (value) {
|
|
48
|
+
this.appendChild(new Text(value));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Append nodes or strings to this fragment.
|
|
53
|
+
*/
|
|
54
|
+
append(...nodes) {
|
|
55
|
+
for (const node of nodes) {
|
|
56
|
+
if (typeof node === "string") {
|
|
57
|
+
this.appendChild(new Text(node));
|
|
58
|
+
} else {
|
|
59
|
+
this.appendChild(node);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Prepend nodes or strings to this fragment.
|
|
65
|
+
*/
|
|
66
|
+
prepend(...nodes) {
|
|
67
|
+
const firstChild = this.firstChild;
|
|
68
|
+
for (const node of nodes) {
|
|
69
|
+
if (typeof node === "string") {
|
|
70
|
+
this.insertBefore(new Text(node), firstChild);
|
|
71
|
+
} else {
|
|
72
|
+
this.insertBefore(node, firstChild);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Replace all children with the given nodes.
|
|
78
|
+
*/
|
|
79
|
+
replaceChildren(...nodes) {
|
|
80
|
+
while (this.firstChild) {
|
|
81
|
+
this.removeChild(this.firstChild);
|
|
82
|
+
}
|
|
83
|
+
this.append(...nodes);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Find an element by ID in this fragment's children.
|
|
87
|
+
*/
|
|
88
|
+
getElementById(id) {
|
|
89
|
+
for (const child of this.children) {
|
|
90
|
+
if (child.id === id) return child;
|
|
91
|
+
const found = this._findById(child, id);
|
|
92
|
+
if (found) return found;
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
_findById(element, id) {
|
|
97
|
+
for (const child of element.children) {
|
|
98
|
+
if (child.id === id) return child;
|
|
99
|
+
const found = this._findById(child, id);
|
|
100
|
+
if (found) return found;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
cloneNode(deep = false) {
|
|
105
|
+
const clone = new DocumentFragment();
|
|
106
|
+
if (deep) {
|
|
107
|
+
for (const child of this.childNodes) {
|
|
108
|
+
clone.appendChild(child.cloneNode(true));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return clone;
|
|
112
|
+
}
|
|
113
|
+
get [Symbol.toStringTag]() {
|
|
114
|
+
return "DocumentFragment";
|
|
115
|
+
}
|
|
112
116
|
};
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { DocumentFragment };
|
package/lib/esm/document.js
CHANGED
|
@@ -1,88 +1,82 @@
|
|
|
1
1
|
import { Node } from "./node.js";
|
|
2
|
+
import { Comment } from "./comment.js";
|
|
3
|
+
import { Text } from "./text.js";
|
|
4
|
+
import { DocumentFragment } from "./document-fragment.js";
|
|
2
5
|
import { HTMLElement } from "./html-element.js";
|
|
3
6
|
import { HTMLImageElement } from "./html-image-element.js";
|
|
4
7
|
import { HTMLVideoElement } from "./html-video-element.js";
|
|
5
8
|
import { HTMLCanvasElement } from "./html-canvas-element.js";
|
|
6
|
-
import { Text } from "./text.js";
|
|
7
|
-
import { Comment } from "./comment.js";
|
|
8
|
-
import { DocumentFragment } from "./document-fragment.js";
|
|
9
9
|
import { Event } from "@gjsify/dom-events";
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
get [Symbol.toStringTag]() {
|
|
81
|
-
return "Document";
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const document = new Document();
|
|
85
|
-
export {
|
|
86
|
-
Document,
|
|
87
|
-
document
|
|
10
|
+
|
|
11
|
+
//#region src/document.ts
|
|
12
|
+
var Document = class Document extends Node {
|
|
13
|
+
static {
|
|
14
|
+
this._elementFactories = new Map();
|
|
15
|
+
}
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.body = new HTMLElement();
|
|
19
|
+
this.head = new HTMLElement();
|
|
20
|
+
this.documentElement = new HTMLElement();
|
|
21
|
+
this.appendChild(this.documentElement);
|
|
22
|
+
this.documentElement.appendChild(this.body);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Register a factory for a custom element tag name.
|
|
26
|
+
* Called as a side-effect by DOM packages to avoid circular dependencies.
|
|
27
|
+
*
|
|
28
|
+
* Example: `Document.registerElementFactory('iframe', () => new HTMLIFrameElement())`
|
|
29
|
+
*/
|
|
30
|
+
static registerElementFactory(tagName, factory) {
|
|
31
|
+
Document._elementFactories.set(tagName.toLowerCase(), factory);
|
|
32
|
+
}
|
|
33
|
+
createElementNS(_namespace, tagName) {
|
|
34
|
+
const tag = tagName.toLowerCase();
|
|
35
|
+
switch (tag) {
|
|
36
|
+
case "img": return new HTMLImageElement();
|
|
37
|
+
case "video": return new HTMLVideoElement();
|
|
38
|
+
case "canvas": return new HTMLCanvasElement();
|
|
39
|
+
default: {
|
|
40
|
+
const factory = Document._elementFactories.get(tag);
|
|
41
|
+
if (factory) return factory();
|
|
42
|
+
return new HTMLElement();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
createElement(tagName) {
|
|
47
|
+
return this.createElementNS("http://www.w3.org/1999/xhtml", tagName);
|
|
48
|
+
}
|
|
49
|
+
createTextNode(data) {
|
|
50
|
+
return new Text(data);
|
|
51
|
+
}
|
|
52
|
+
createComment(data) {
|
|
53
|
+
return new Comment(data);
|
|
54
|
+
}
|
|
55
|
+
createDocumentFragment() {
|
|
56
|
+
return new DocumentFragment();
|
|
57
|
+
}
|
|
58
|
+
createEvent(type) {
|
|
59
|
+
return new Event(type);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Find an element by ID. Searches body's descendants.
|
|
63
|
+
*/
|
|
64
|
+
getElementById(id) {
|
|
65
|
+
return this._findById(this.body, id);
|
|
66
|
+
}
|
|
67
|
+
_findById(element, id) {
|
|
68
|
+
if (element.id === id) return element;
|
|
69
|
+
for (const child of element.children) {
|
|
70
|
+
const found = this._findById(child, id);
|
|
71
|
+
if (found) return found;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
get [Symbol.toStringTag]() {
|
|
76
|
+
return "Document";
|
|
77
|
+
}
|
|
88
78
|
};
|
|
79
|
+
const document = new Document();
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
export { Document, document };
|