@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.
Files changed (41) hide show
  1. package/lib/esm/_virtual/_rolldown/runtime.js +18 -0
  2. package/lib/esm/attr.js +37 -30
  3. package/lib/esm/character-data.js +61 -54
  4. package/lib/esm/comment.js +26 -19
  5. package/lib/esm/document-fragment.js +116 -109
  6. package/lib/esm/document.js +75 -81
  7. package/lib/esm/dom-matrix.js +158 -123
  8. package/lib/esm/dom-token-list.js +114 -108
  9. package/lib/esm/element.js +244 -246
  10. package/lib/esm/font-face.js +94 -89
  11. package/lib/esm/gst-time.js +17 -6
  12. package/lib/esm/html-canvas-element.js +82 -75
  13. package/lib/esm/html-element.js +424 -424
  14. package/lib/esm/html-image-element.js +226 -225
  15. package/lib/esm/html-media-element.js +117 -114
  16. package/lib/esm/html-video-element.js +110 -108
  17. package/lib/esm/image.js +27 -21
  18. package/lib/esm/index.js +13 -45
  19. package/lib/esm/intersection-observer.js +22 -18
  20. package/lib/esm/location-stub.js +25 -23
  21. package/lib/esm/match-media.js +18 -19
  22. package/lib/esm/mutation-observer.js +18 -13
  23. package/lib/esm/named-node-map.js +121 -121
  24. package/lib/esm/namespace-uri.js +9 -8
  25. package/lib/esm/node-list.js +39 -33
  26. package/lib/esm/node-type.js +13 -12
  27. package/lib/esm/node.js +241 -246
  28. package/lib/esm/property-symbol.js +36 -30
  29. package/lib/esm/register/canvas.js +11 -7
  30. package/lib/esm/register/document.js +19 -18
  31. package/lib/esm/register/font-face.js +10 -6
  32. package/lib/esm/register/helpers.js +14 -12
  33. package/lib/esm/register/image.js +4 -0
  34. package/lib/esm/register/location.js +4 -0
  35. package/lib/esm/register/match-media.js +4 -0
  36. package/lib/esm/register/navigator.js +4 -1
  37. package/lib/esm/register/observers.js +5 -1
  38. package/lib/esm/resize-observer.js +15 -12
  39. package/lib/esm/text.js +56 -49
  40. package/lib/esm/types/index.js +3 -3
  41. package/package.json +11 -11
@@ -1,25 +1,27 @@
1
+ //#region src/location-stub.ts
1
2
  const location = {
2
- href: "file://",
3
- origin: "file://",
4
- protocol: "file:",
5
- host: "",
6
- hostname: "",
7
- port: "",
8
- pathname: "/",
9
- search: "",
10
- hash: "",
11
- assign(_url) {
12
- },
13
- replace(_url) {
14
- },
15
- reload() {
16
- },
17
- toString() {
18
- return this.href;
19
- },
20
- ancestorOrigins: { length: 0, item: () => null, contains: () => false, [Symbol.iterator]: function* () {
21
- } }
22
- };
23
- export {
24
- location
3
+ href: "file://",
4
+ origin: "file://",
5
+ protocol: "file:",
6
+ host: "",
7
+ hostname: "",
8
+ port: "",
9
+ pathname: "/",
10
+ search: "",
11
+ hash: "",
12
+ assign(_url) {},
13
+ replace(_url) {},
14
+ reload() {},
15
+ toString() {
16
+ return this.href;
17
+ },
18
+ ancestorOrigins: {
19
+ length: 0,
20
+ item: () => null,
21
+ contains: () => false,
22
+ [Symbol.iterator]: function* () {}
23
+ }
25
24
  };
25
+
26
+ //#endregion
27
+ export { location };
@@ -1,22 +1,21 @@
1
1
  import { EventTarget } from "@gjsify/dom-events";
2
- class MediaQueryList extends EventTarget {
3
- constructor(query) {
4
- super();
5
- this.onchange = null;
6
- this.media = query;
7
- this.matches = false;
8
- }
9
- /** @deprecated Use addEventListener('change', ...) */
10
- addListener(_listener) {
11
- }
12
- /** @deprecated Use removeEventListener('change', ...) */
13
- removeListener(_listener) {
14
- }
15
- }
2
+
3
+ //#region src/match-media.ts
4
+ var MediaQueryList = class extends EventTarget {
5
+ constructor(query) {
6
+ super();
7
+ this.onchange = null;
8
+ this.media = query;
9
+ this.matches = false;
10
+ }
11
+ /** @deprecated Use addEventListener('change', ...) */
12
+ addListener(_listener) {}
13
+ /** @deprecated Use removeEventListener('change', ...) */
14
+ removeListener(_listener) {}
15
+ };
16
16
  function matchMedia(query) {
17
- return new MediaQueryList(query);
17
+ return new MediaQueryList(query);
18
18
  }
19
- export {
20
- MediaQueryList,
21
- matchMedia
22
- };
19
+
20
+ //#endregion
21
+ export { MediaQueryList, matchMedia };
@@ -1,14 +1,19 @@
1
- class MutationObserver {
2
- constructor(_callback) {
3
- }
4
- observe(_target, _options) {
5
- }
6
- disconnect() {
7
- }
8
- takeRecords() {
9
- return [];
10
- }
11
- }
12
- export {
13
- MutationObserver
1
+ //#region src/mutation-observer.ts
2
+ /**
3
+ * MutationObserver stub.
4
+ * Many libraries check for MutationObserver existence; this prevents crashes.
5
+ * Does not actually observe DOM mutations (no layout engine).
6
+ *
7
+ * Reference: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
8
+ */
9
+ var MutationObserver = class {
10
+ constructor(_callback) {}
11
+ observe(_target, _options) {}
12
+ disconnect() {}
13
+ takeRecords() {
14
+ return [];
15
+ }
14
16
  };
17
+
18
+ //#endregion
19
+ export { MutationObserver };
@@ -1,124 +1,124 @@
1
1
  import { Attr } from "./attr.js";
2
2
  import { NamespaceURI } from "./namespace-uri.js";
3
- class NamedNodeMap {
4
- constructor(ownerElement) {
5
- this._items = [];
6
- this._ownerElement = ownerElement;
7
- }
8
- get length() {
9
- return this._items.length;
10
- }
11
- item(index) {
12
- return this._items[index] ?? null;
13
- }
14
- getNamedItem(qualifiedName) {
15
- return this._findByName(qualifiedName);
16
- }
17
- getNamedItemNS(namespace, localName) {
18
- const ns = namespace === "" ? null : namespace;
19
- for (const attr of this._items) {
20
- if (attr.namespaceURI === ns && attr.localName === localName) {
21
- return attr;
22
- }
23
- }
24
- return null;
25
- }
26
- setNamedItem(attr) {
27
- return this._setAttr(attr);
28
- }
29
- setNamedItemNS(attr) {
30
- return this._setAttr(attr);
31
- }
32
- removeNamedItem(qualifiedName) {
33
- const existing = this._findByName(qualifiedName);
34
- if (!existing) {
35
- throw new DOMException(
36
- `Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${qualifiedName}' was found.`,
37
- "NotFoundError"
38
- );
39
- }
40
- this._removeAttr(existing);
41
- return existing;
42
- }
43
- removeNamedItemNS(namespace, localName) {
44
- const existing = this.getNamedItemNS(namespace, localName);
45
- if (!existing) {
46
- throw new DOMException(
47
- `Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with namespace '${namespace}' and localName '${localName}' was found.`,
48
- "NotFoundError"
49
- );
50
- }
51
- this._removeAttr(existing);
52
- return existing;
53
- }
54
- [Symbol.iterator]() {
55
- return this._items[Symbol.iterator]();
56
- }
57
- get [Symbol.toStringTag]() {
58
- return "NamedNodeMap";
59
- }
60
- // -- Internal helpers --
61
- /** @internal Add or replace an attribute by name. */
62
- _setNamedItem(name, value, namespaceURI = null, prefix = null) {
63
- const existing = namespaceURI !== null ? this.getNamedItemNS(namespaceURI, name.includes(":") ? name.split(":")[1] : name) : this._findByName(name);
64
- if (existing) {
65
- existing.value = value;
66
- } else {
67
- const attr = new Attr(name, value, namespaceURI, prefix, this._ownerElement);
68
- this._items.push(attr);
69
- }
70
- }
71
- /** @internal Remove an attribute by name. Returns true if removed. */
72
- _removeNamedItem(name) {
73
- const existing = this._findByName(name);
74
- if (existing) {
75
- this._removeAttr(existing);
76
- return true;
77
- }
78
- return false;
79
- }
80
- /** @internal Remove an attribute by namespace + localName. Returns true if removed. */
81
- _removeNamedItemNS(namespace, localName) {
82
- const existing = this.getNamedItemNS(namespace, localName);
83
- if (existing) {
84
- this._removeAttr(existing);
85
- return true;
86
- }
87
- return false;
88
- }
89
- _findByName(qualifiedName) {
90
- const isHTML = this._ownerElement.namespaceURI === NamespaceURI.html;
91
- const searchName = isHTML ? qualifiedName.toLowerCase() : qualifiedName;
92
- for (const attr of this._items) {
93
- const attrName = isHTML ? attr.name.toLowerCase() : attr.name;
94
- if (attrName === searchName) {
95
- return attr;
96
- }
97
- }
98
- return null;
99
- }
100
- _setAttr(attr) {
101
- let existing = null;
102
- if (attr.namespaceURI !== null) {
103
- existing = this.getNamedItemNS(attr.namespaceURI, attr.localName);
104
- } else {
105
- existing = this._findByName(attr.name);
106
- }
107
- if (existing) {
108
- const oldAttr = new Attr(existing.name, existing.value, existing.namespaceURI, existing.prefix, existing.ownerElement);
109
- existing.value = attr.value;
110
- return oldAttr;
111
- }
112
- this._items.push(attr);
113
- return null;
114
- }
115
- _removeAttr(attr) {
116
- const idx = this._items.indexOf(attr);
117
- if (idx !== -1) {
118
- this._items.splice(idx, 1);
119
- }
120
- }
121
- }
122
- export {
123
- NamedNodeMap
3
+
4
+ //#region src/named-node-map.ts
5
+ /**
6
+ * Simplified NamedNodeMap for attribute storage.
7
+ *
8
+ * Reference: https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap
9
+ */
10
+ var NamedNodeMap = class {
11
+ constructor(ownerElement) {
12
+ this._items = [];
13
+ this._ownerElement = ownerElement;
14
+ }
15
+ get length() {
16
+ return this._items.length;
17
+ }
18
+ item(index) {
19
+ return this._items[index] ?? null;
20
+ }
21
+ getNamedItem(qualifiedName) {
22
+ return this._findByName(qualifiedName);
23
+ }
24
+ getNamedItemNS(namespace, localName) {
25
+ const ns = namespace === "" ? null : namespace;
26
+ for (const attr of this._items) {
27
+ if (attr.namespaceURI === ns && attr.localName === localName) {
28
+ return attr;
29
+ }
30
+ }
31
+ return null;
32
+ }
33
+ setNamedItem(attr) {
34
+ return this._setAttr(attr);
35
+ }
36
+ setNamedItemNS(attr) {
37
+ return this._setAttr(attr);
38
+ }
39
+ removeNamedItem(qualifiedName) {
40
+ const existing = this._findByName(qualifiedName);
41
+ if (!existing) {
42
+ throw new DOMException(`Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${qualifiedName}' was found.`, "NotFoundError");
43
+ }
44
+ this._removeAttr(existing);
45
+ return existing;
46
+ }
47
+ removeNamedItemNS(namespace, localName) {
48
+ const existing = this.getNamedItemNS(namespace, localName);
49
+ if (!existing) {
50
+ throw new DOMException(`Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with namespace '${namespace}' and localName '${localName}' was found.`, "NotFoundError");
51
+ }
52
+ this._removeAttr(existing);
53
+ return existing;
54
+ }
55
+ [Symbol.iterator]() {
56
+ return this._items[Symbol.iterator]();
57
+ }
58
+ get [Symbol.toStringTag]() {
59
+ return "NamedNodeMap";
60
+ }
61
+ /** @internal Add or replace an attribute by name. */
62
+ _setNamedItem(name, value, namespaceURI = null, prefix = null) {
63
+ const existing = namespaceURI !== null ? this.getNamedItemNS(namespaceURI, name.includes(":") ? name.split(":")[1] : name) : this._findByName(name);
64
+ if (existing) {
65
+ existing.value = value;
66
+ } else {
67
+ const attr = new Attr(name, value, namespaceURI, prefix, this._ownerElement);
68
+ this._items.push(attr);
69
+ }
70
+ }
71
+ /** @internal Remove an attribute by name. Returns true if removed. */
72
+ _removeNamedItem(name) {
73
+ const existing = this._findByName(name);
74
+ if (existing) {
75
+ this._removeAttr(existing);
76
+ return true;
77
+ }
78
+ return false;
79
+ }
80
+ /** @internal Remove an attribute by namespace + localName. Returns true if removed. */
81
+ _removeNamedItemNS(namespace, localName) {
82
+ const existing = this.getNamedItemNS(namespace, localName);
83
+ if (existing) {
84
+ this._removeAttr(existing);
85
+ return true;
86
+ }
87
+ return false;
88
+ }
89
+ _findByName(qualifiedName) {
90
+ const isHTML = this._ownerElement.namespaceURI === NamespaceURI.html;
91
+ const searchName = isHTML ? qualifiedName.toLowerCase() : qualifiedName;
92
+ for (const attr of this._items) {
93
+ const attrName = isHTML ? attr.name.toLowerCase() : attr.name;
94
+ if (attrName === searchName) {
95
+ return attr;
96
+ }
97
+ }
98
+ return null;
99
+ }
100
+ _setAttr(attr) {
101
+ let existing = null;
102
+ if (attr.namespaceURI !== null) {
103
+ existing = this.getNamedItemNS(attr.namespaceURI, attr.localName);
104
+ } else {
105
+ existing = this._findByName(attr.name);
106
+ }
107
+ if (existing) {
108
+ const oldAttr = new Attr(existing.name, existing.value, existing.namespaceURI, existing.prefix, existing.ownerElement);
109
+ existing.value = attr.value;
110
+ return oldAttr;
111
+ }
112
+ this._items.push(attr);
113
+ return null;
114
+ }
115
+ _removeAttr(attr) {
116
+ const idx = this._items.indexOf(attr);
117
+ if (idx !== -1) {
118
+ this._items.splice(idx, 1);
119
+ }
120
+ }
124
121
  };
122
+
123
+ //#endregion
124
+ export { NamedNodeMap };
@@ -1,10 +1,11 @@
1
+ //#region src/namespace-uri.ts
1
2
  const NamespaceURI = {
2
- html: "http://www.w3.org/1999/xhtml",
3
- svg: "http://www.w3.org/2000/svg",
4
- mathML: "http://www.w3.org/1998/Math/MathML",
5
- xml: "http://www.w3.org/XML/1998/namespace",
6
- xmlns: "http://www.w3.org/2000/xmlns/"
7
- };
8
- export {
9
- NamespaceURI
3
+ html: "http://www.w3.org/1999/xhtml",
4
+ svg: "http://www.w3.org/2000/svg",
5
+ mathML: "http://www.w3.org/1998/Math/MathML",
6
+ xml: "http://www.w3.org/XML/1998/namespace",
7
+ xmlns: "http://www.w3.org/2000/xmlns/"
10
8
  };
9
+
10
+ //#endregion
11
+ export { NamespaceURI };
@@ -1,34 +1,40 @@
1
- class NodeList {
2
- constructor(items) {
3
- this._items = items;
4
- }
5
- get length() {
6
- return this._items.length;
7
- }
8
- item(index) {
9
- return this._items[index] ?? null;
10
- }
11
- forEach(callback, thisArg) {
12
- for (let i = 0; i < this._items.length; i++) {
13
- callback.call(thisArg, this._items[i], i, this);
14
- }
15
- }
16
- entries() {
17
- return this._items.entries();
18
- }
19
- keys() {
20
- return this._items.keys();
21
- }
22
- values() {
23
- return this._items.values();
24
- }
25
- [Symbol.iterator]() {
26
- return this._items[Symbol.iterator]();
27
- }
28
- get [Symbol.toStringTag]() {
29
- return "NodeList";
30
- }
31
- }
32
- export {
33
- NodeList
1
+ //#region src/node-list.ts
2
+ /**
3
+ * Minimal NodeList backed by an external array.
4
+ *
5
+ * Reference: https://developer.mozilla.org/en-US/docs/Web/API/NodeList
6
+ */
7
+ var NodeList = class {
8
+ constructor(items) {
9
+ this._items = items;
10
+ }
11
+ get length() {
12
+ return this._items.length;
13
+ }
14
+ item(index) {
15
+ return this._items[index] ?? null;
16
+ }
17
+ forEach(callback, thisArg) {
18
+ for (let i = 0; i < this._items.length; i++) {
19
+ callback.call(thisArg, this._items[i], i, this);
20
+ }
21
+ }
22
+ entries() {
23
+ return this._items.entries();
24
+ }
25
+ keys() {
26
+ return this._items.keys();
27
+ }
28
+ values() {
29
+ return this._items.values();
30
+ }
31
+ [Symbol.iterator]() {
32
+ return this._items[Symbol.iterator]();
33
+ }
34
+ get [Symbol.toStringTag]() {
35
+ return "NodeList";
36
+ }
34
37
  };
38
+
39
+ //#endregion
40
+ export { NodeList };
@@ -1,14 +1,15 @@
1
+ //#region src/node-type.ts
1
2
  const NodeType = {
2
- ELEMENT_NODE: 1,
3
- ATTRIBUTE_NODE: 2,
4
- TEXT_NODE: 3,
5
- CDATA_SECTION_NODE: 4,
6
- PROCESSING_INSTRUCTION_NODE: 7,
7
- COMMENT_NODE: 8,
8
- DOCUMENT_NODE: 9,
9
- DOCUMENT_TYPE_NODE: 10,
10
- DOCUMENT_FRAGMENT_NODE: 11
11
- };
12
- export {
13
- NodeType
3
+ ELEMENT_NODE: 1,
4
+ ATTRIBUTE_NODE: 2,
5
+ TEXT_NODE: 3,
6
+ CDATA_SECTION_NODE: 4,
7
+ PROCESSING_INSTRUCTION_NODE: 7,
8
+ COMMENT_NODE: 8,
9
+ DOCUMENT_NODE: 9,
10
+ DOCUMENT_TYPE_NODE: 10,
11
+ DOCUMENT_FRAGMENT_NODE: 11
14
12
  };
13
+
14
+ //#endregion
15
+ export { NodeType };