@remote-dom/polyfill 0.0.1

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 (168) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +45 -0
  3. package/build/cjs/Attr.cjs +54 -0
  4. package/build/cjs/CharacterData.cjs +29 -0
  5. package/build/cjs/ChildNode.cjs +45 -0
  6. package/build/cjs/Comment.cjs +11 -0
  7. package/build/cjs/CustomElementRegistry.cjs +35 -0
  8. package/build/cjs/CustomEvent.cjs +28 -0
  9. package/build/cjs/Document.cjs +94 -0
  10. package/build/cjs/DocumentFragment.cjs +12 -0
  11. package/build/cjs/Element.cjs +81 -0
  12. package/build/cjs/Event.cjs +113 -0
  13. package/build/cjs/EventTarget.cjs +101 -0
  14. package/build/cjs/HTMLElement.cjs +7 -0
  15. package/build/cjs/HTMLTemplateElement.cjs +26 -0
  16. package/build/cjs/MutationObserver.cjs +7 -0
  17. package/build/cjs/NamedNodeMap.cjs +115 -0
  18. package/build/cjs/Node.cjs +102 -0
  19. package/build/cjs/NodeList.cjs +9 -0
  20. package/build/cjs/ParentNode.cjs +130 -0
  21. package/build/cjs/SVGElement.cjs +19 -0
  22. package/build/cjs/Text.cjs +11 -0
  23. package/build/cjs/Window.cjs +69 -0
  24. package/build/cjs/constants.cjs +57 -0
  25. package/build/cjs/hooks.cjs +5 -0
  26. package/build/cjs/index.cjs +10 -0
  27. package/build/cjs/selectors.cjs +203 -0
  28. package/build/cjs/serialization.cjs +96 -0
  29. package/build/cjs/shared.cjs +63 -0
  30. package/build/esm/Attr.mjs +52 -0
  31. package/build/esm/CharacterData.mjs +27 -0
  32. package/build/esm/ChildNode.mjs +42 -0
  33. package/build/esm/Comment.mjs +9 -0
  34. package/build/esm/CustomElementRegistry.mjs +33 -0
  35. package/build/esm/CustomEvent.mjs +26 -0
  36. package/build/esm/Document.mjs +89 -0
  37. package/build/esm/DocumentFragment.mjs +10 -0
  38. package/build/esm/Element.mjs +95 -0
  39. package/build/esm/Event.mjs +108 -0
  40. package/build/esm/EventTarget.mjs +99 -0
  41. package/build/esm/HTMLElement.mjs +5 -0
  42. package/build/esm/HTMLTemplateElement.mjs +24 -0
  43. package/build/esm/MutationObserver.mjs +5 -0
  44. package/build/esm/NamedNodeMap.mjs +121 -0
  45. package/build/esm/Node.mjs +100 -0
  46. package/build/esm/NodeList.mjs +7 -0
  47. package/build/esm/ParentNode.mjs +128 -0
  48. package/build/esm/SVGElement.mjs +17 -0
  49. package/build/esm/Text.mjs +9 -0
  50. package/build/esm/Window.mjs +66 -0
  51. package/build/esm/constants.mjs +39 -0
  52. package/build/esm/hooks.mjs +3 -0
  53. package/build/esm/index.mjs +2 -0
  54. package/build/esm/selectors.mjs +197 -0
  55. package/build/esm/serialization.mjs +92 -0
  56. package/build/esm/shared.mjs +55 -0
  57. package/build/esnext/Attr.esnext +57 -0
  58. package/build/esnext/CharacterData.esnext +27 -0
  59. package/build/esnext/ChildNode.esnext +47 -0
  60. package/build/esnext/Comment.esnext +9 -0
  61. package/build/esnext/CustomElementRegistry.esnext +34 -0
  62. package/build/esnext/CustomEvent.esnext +25 -0
  63. package/build/esnext/Document.esnext +86 -0
  64. package/build/esnext/DocumentFragment.esnext +10 -0
  65. package/build/esnext/Element.esnext +99 -0
  66. package/build/esnext/Event.esnext +109 -0
  67. package/build/esnext/EventTarget.esnext +99 -0
  68. package/build/esnext/HTMLElement.esnext +6 -0
  69. package/build/esnext/HTMLTemplateElement.esnext +26 -0
  70. package/build/esnext/MutationObserver.esnext +5 -0
  71. package/build/esnext/NamedNodeMap.esnext +131 -0
  72. package/build/esnext/Node.esnext +116 -0
  73. package/build/esnext/NodeList.esnext +7 -0
  74. package/build/esnext/ParentNode.esnext +138 -0
  75. package/build/esnext/SVGElement.esnext +17 -0
  76. package/build/esnext/Text.esnext +9 -0
  77. package/build/esnext/Window.esnext +59 -0
  78. package/build/esnext/constants.esnext +37 -0
  79. package/build/esnext/hooks.esnext +3 -0
  80. package/build/esnext/index.esnext +2 -0
  81. package/build/esnext/selectors.esnext +169 -0
  82. package/build/esnext/serialization.esnext +76 -0
  83. package/build/esnext/shared.esnext +59 -0
  84. package/build/tsconfig.tsbuildinfo +1 -0
  85. package/build/typescript/Attr.d.ts +24 -0
  86. package/build/typescript/Attr.d.ts.map +1 -0
  87. package/build/typescript/CharacterData.d.ts +10 -0
  88. package/build/typescript/CharacterData.d.ts.map +1 -0
  89. package/build/typescript/ChildNode.d.ts +10 -0
  90. package/build/typescript/ChildNode.d.ts.map +1 -0
  91. package/build/typescript/Comment.d.ts +7 -0
  92. package/build/typescript/Comment.d.ts.map +1 -0
  93. package/build/typescript/CustomElementRegistry.d.ts +9 -0
  94. package/build/typescript/CustomElementRegistry.d.ts.map +1 -0
  95. package/build/typescript/CustomEvent.d.ts +17 -0
  96. package/build/typescript/CustomEvent.d.ts.map +1 -0
  97. package/build/typescript/Document.d.ts +27 -0
  98. package/build/typescript/Document.d.ts.map +1 -0
  99. package/build/typescript/DocumentFragment.d.ts +8 -0
  100. package/build/typescript/DocumentFragment.d.ts.map +1 -0
  101. package/build/typescript/Element.d.ts +32 -0
  102. package/build/typescript/Element.d.ts.map +1 -0
  103. package/build/typescript/Event.d.ts +47 -0
  104. package/build/typescript/Event.d.ts.map +1 -0
  105. package/build/typescript/EventTarget.d.ts +12 -0
  106. package/build/typescript/EventTarget.d.ts.map +1 -0
  107. package/build/typescript/HTMLElement.d.ts +4 -0
  108. package/build/typescript/HTMLElement.d.ts.map +1 -0
  109. package/build/typescript/HTMLTemplateElement.d.ts +11 -0
  110. package/build/typescript/HTMLTemplateElement.d.ts.map +1 -0
  111. package/build/typescript/MutationObserver.d.ts +3 -0
  112. package/build/typescript/MutationObserver.d.ts.map +1 -0
  113. package/build/typescript/NamedNodeMap.d.ts +18 -0
  114. package/build/typescript/NamedNodeMap.d.ts.map +1 -0
  115. package/build/typescript/Node.d.ts +37 -0
  116. package/build/typescript/Node.d.ts.map +1 -0
  117. package/build/typescript/NodeList.d.ts +4 -0
  118. package/build/typescript/NodeList.d.ts.map +1 -0
  119. package/build/typescript/ParentNode.d.ts +18 -0
  120. package/build/typescript/ParentNode.d.ts.map +1 -0
  121. package/build/typescript/SVGElement.d.ts +7 -0
  122. package/build/typescript/SVGElement.d.ts.map +1 -0
  123. package/build/typescript/Text.d.ts +7 -0
  124. package/build/typescript/Text.d.ts.map +1 -0
  125. package/build/typescript/Window.d.ts +45 -0
  126. package/build/typescript/Window.d.ts.map +1 -0
  127. package/build/typescript/constants.d.ts +35 -0
  128. package/build/typescript/constants.d.ts.map +1 -0
  129. package/build/typescript/hooks.d.ts +13 -0
  130. package/build/typescript/hooks.d.ts.map +1 -0
  131. package/build/typescript/index.d.ts +3 -0
  132. package/build/typescript/index.d.ts.map +1 -0
  133. package/build/typescript/selectors.d.ts +32 -0
  134. package/build/typescript/selectors.d.ts.map +1 -0
  135. package/build/typescript/serialization.d.ts +6 -0
  136. package/build/typescript/serialization.d.ts.map +1 -0
  137. package/build/typescript/shared.d.ts +16 -0
  138. package/build/typescript/shared.d.ts.map +1 -0
  139. package/package.json +35 -0
  140. package/rollup.config.js +3 -0
  141. package/source/Attr.ts +70 -0
  142. package/source/CharacterData.ts +29 -0
  143. package/source/ChildNode.ts +45 -0
  144. package/source/Comment.ts +7 -0
  145. package/source/CustomElementRegistry.ts +52 -0
  146. package/source/CustomEvent.ts +30 -0
  147. package/source/Document.ts +112 -0
  148. package/source/DocumentFragment.ts +8 -0
  149. package/source/Element.ts +119 -0
  150. package/source/Event.ts +142 -0
  151. package/source/EventTarget.ts +139 -0
  152. package/source/HTMLElement.ts +3 -0
  153. package/source/HTMLTemplateElement.ts +28 -0
  154. package/source/MutationObserver.ts +3 -0
  155. package/source/NamedNodeMap.ts +156 -0
  156. package/source/Node.ts +139 -0
  157. package/source/NodeList.ts +5 -0
  158. package/source/ParentNode.ts +158 -0
  159. package/source/SVGElement.ts +16 -0
  160. package/source/Text.ts +7 -0
  161. package/source/Window.ts +64 -0
  162. package/source/constants.ts +37 -0
  163. package/source/hooks.ts +28 -0
  164. package/source/index.ts +2 -0
  165. package/source/selectors.ts +230 -0
  166. package/source/serialization.ts +110 -0
  167. package/source/shared.ts +80 -0
  168. package/tsconfig.json +10 -0
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+ var Element = require('./Element.cjs');
5
+ var serialization = require('./serialization.cjs');
6
+
7
+ class HTMLTemplateElement extends Element.Element {
8
+ get content() {
9
+ let content = this[constants.CONTENT];
10
+ if (!content) {
11
+ content = this.ownerDocument.createDocumentFragment();
12
+ this[constants.CONTENT] = content;
13
+ }
14
+ return content;
15
+ }
16
+ set content(_) {}
17
+ set innerHTML(html) {
18
+ this.content.replaceChildren(serialization.parseHtml(String(html), this));
19
+ }
20
+ get innerHTML() {
21
+ const content = this[constants.CONTENT];
22
+ return content ? serialization.serializeChildren(content) : '';
23
+ }
24
+ }
25
+
26
+ exports.HTMLTemplateElement = HTMLTemplateElement;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ class MutationObserver {
4
+ // stub implementation
5
+ }
6
+
7
+ exports.MutationObserver = MutationObserver;
@@ -0,0 +1,115 @@
1
+ 'use strict';
2
+
3
+ var hooks = require('./hooks.cjs');
4
+ var constants = require('./constants.cjs');
5
+
6
+ class NamedNodeMap {
7
+ [constants.CHILD] = null;
8
+ constructor(ownerElement) {
9
+ this[constants.OWNER_ELEMENT] = ownerElement;
10
+ }
11
+ getNamedItem(name) {
12
+ return this.getNamedItemNS(null, name);
13
+ }
14
+ getNamedItemNS(namespaceURI, name) {
15
+ let attr = this[constants.CHILD];
16
+ while (attr) {
17
+ if (attr.name === name && attr[constants.NS] == namespaceURI) {
18
+ return attr;
19
+ }
20
+ attr = attr[constants.NEXT];
21
+ }
22
+ return null;
23
+ }
24
+ item(index) {
25
+ let attr = this[constants.CHILD];
26
+ let i = 0;
27
+ while (attr) {
28
+ if (i++ === index) return attr;
29
+ attr = attr[constants.NEXT];
30
+ }
31
+ return null;
32
+ }
33
+ get length() {
34
+ let index = 0;
35
+ let attr = this[constants.CHILD];
36
+ while (attr) {
37
+ index++;
38
+ attr = attr[constants.NEXT];
39
+ }
40
+ return index;
41
+ }
42
+ removeNamedItem(name) {
43
+ return this.removeNamedItemNS(null, name);
44
+ }
45
+ removeNamedItemNS(namespaceURI, name) {
46
+ const ownerElement = this[constants.OWNER_ELEMENT];
47
+ let attr = this[constants.CHILD];
48
+ let prev = null;
49
+ while (attr != null) {
50
+ if (attr.name === name && attr[constants.NS] == namespaceURI) {
51
+ if (prev) prev[constants.NEXT] = attr[constants.NEXT];
52
+ if (this[constants.CHILD] === attr) this[constants.CHILD] = attr[constants.NEXT];
53
+ updateElementAttribute(ownerElement, attr.name, attr.value, null);
54
+ hooks.hooks.removeAttribute?.(ownerElement, name, namespaceURI);
55
+ return attr;
56
+ }
57
+ prev = attr;
58
+ attr = attr[constants.NEXT];
59
+ }
60
+ return null;
61
+ }
62
+ setNamedItem(attr) {
63
+ const ownerElement = this[constants.OWNER_ELEMENT];
64
+ let old = null;
65
+ let child = this[constants.CHILD];
66
+ attr[constants.OWNER_ELEMENT] = ownerElement;
67
+ if (child == null) {
68
+ this[constants.CHILD] = attr;
69
+ // return null;
70
+ } else {
71
+ let prev;
72
+ while (child) {
73
+ if (child.name === attr.name && child[constants.NS] == attr[constants.NS]) {
74
+ if (prev) prev[constants.NEXT] = attr;else this[constants.CHILD] = attr;
75
+ attr[constants.NEXT] = child[constants.NEXT];
76
+ child[constants.NEXT] = null;
77
+ old = child;
78
+ break;
79
+ // return child;
80
+ }
81
+
82
+ prev = child;
83
+ child = child[constants.NEXT];
84
+ }
85
+ if (prev) prev[constants.NEXT] = attr;else this[constants.CHILD] = attr;
86
+ // return null;
87
+ }
88
+ // only invoke the protocol if the value changed
89
+ if (!old || old.value !== attr.value) {
90
+ updateElementAttribute(ownerElement, attr.name, old?.value ?? null, attr.value);
91
+ hooks.hooks.setAttribute?.(ownerElement, attr.name, attr.value, attr[constants.NS]);
92
+ }
93
+ return old;
94
+ }
95
+ setNamedItemNS(attr) {
96
+ return this.setNamedItem(attr);
97
+ }
98
+ }
99
+ function updateElementAttribute(element, name, oldValue, newValue) {
100
+ const {
101
+ observedAttributes
102
+ } = element.constructor;
103
+ const {
104
+ attributeChangedCallback
105
+ } = element;
106
+ if (name === 'slot' && element.slot !== newValue) {
107
+ element.slot = newValue ?? '';
108
+ }
109
+ if (attributeChangedCallback == null || observedAttributes == null || !observedAttributes.includes(name)) {
110
+ return;
111
+ }
112
+ return attributeChangedCallback.call(element, name, oldValue, newValue);
113
+ }
114
+
115
+ exports.NamedNodeMap = NamedNodeMap;
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+ var EventTarget = require('./EventTarget.cjs');
5
+ var shared = require('./shared.cjs');
6
+
7
+ class Node extends EventTarget.EventTarget {
8
+ nodeType = constants.NodeType.NODE;
9
+ [constants.NAME] = '';
10
+ [constants.PARENT] = null;
11
+ [constants.CHILD] = null;
12
+ [constants.PREV] = null;
13
+ [constants.NEXT] = null;
14
+ get localName() {
15
+ return this[constants.NAME];
16
+ }
17
+ get nodeName() {
18
+ return this[constants.NAME].toUpperCase();
19
+ }
20
+ get ownerDocument() {
21
+ return this[constants.OWNER_DOCUMENT];
22
+ }
23
+ isDefaultNamespace(namespace) {
24
+ return namespace === constants.NamespaceURI.XHTML;
25
+ }
26
+ get parentNode() {
27
+ return this[constants.PARENT];
28
+ }
29
+ set parentNode(_readonly) {}
30
+ get previousSibling() {
31
+ return this[constants.PREV];
32
+ }
33
+ set previousSibling(_readonly) {}
34
+ get nextSibling() {
35
+ return this[constants.NEXT];
36
+ }
37
+ set nextSibling(_readonly) {}
38
+ get previousElementSibling() {
39
+ let sib = this[constants.PREV];
40
+ while (sib && sib.nodeType !== 1) sib = sib[constants.PREV];
41
+ return sib;
42
+ }
43
+ set previousElementSibling(_readonly) {}
44
+ get nextElementSibling() {
45
+ let sib = this[constants.NEXT];
46
+ while (sib && sib.nodeType !== 1) sib = sib[constants.NEXT];
47
+ return sib;
48
+ }
49
+ set nextElementSibling(_readonly) {}
50
+ get firstChild() {
51
+ return this[constants.CHILD];
52
+ }
53
+ set firstChild(_readonly) {}
54
+ get lastChild() {
55
+ let child = this[constants.CHILD];
56
+ while (child) {
57
+ const next = child[constants.NEXT];
58
+ if (next == null) break;
59
+ child = next;
60
+ }
61
+ return child;
62
+ }
63
+ set lastChild(_readonly) {}
64
+ get nodeValue() {
65
+ if (shared.isCharacterData(this)) return this.data;
66
+ return null;
67
+ }
68
+ set nodeValue(data) {
69
+ if (shared.isCharacterData(this)) this.data = data;
70
+ }
71
+ get textContent() {
72
+ if (shared.isCharacterData(this)) return this.data;
73
+ let text = '';
74
+ function walk(node) {
75
+ if (shared.isTextNode(node)) {
76
+ text += node.data;
77
+ }
78
+ const child = node[constants.CHILD];
79
+ if (child) walk(child);
80
+ const sibling = node[constants.NEXT];
81
+ if (sibling) walk(sibling);
82
+ }
83
+ walk(this);
84
+ return text;
85
+ }
86
+ set textContent(data) {
87
+ if (shared.isCharacterData(this)) {
88
+ this.data = data;
89
+ } else if (shared.isParentNode(this)) {
90
+ let child;
91
+ while (child = this[constants.CHILD]) {
92
+ this.removeChild(child);
93
+ }
94
+ this.append(data);
95
+ }
96
+ }
97
+ cloneNode(deep) {
98
+ return shared.cloneNode(this, deep);
99
+ }
100
+ }
101
+
102
+ exports.Node = Node;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ class NodeList extends Array {
4
+ item(index) {
5
+ return this[index];
6
+ }
7
+ }
8
+
9
+ exports.NodeList = NodeList;
@@ -0,0 +1,130 @@
1
+ 'use strict';
2
+
3
+ var hooks = require('./hooks.cjs');
4
+ var constants = require('./constants.cjs');
5
+ var ChildNode = require('./ChildNode.cjs');
6
+ var NodeList = require('./NodeList.cjs');
7
+ var selectors = require('./selectors.cjs');
8
+
9
+ class ParentNode extends ChildNode.ChildNode {
10
+ childNodes = new NodeList.NodeList();
11
+ children = new NodeList.NodeList();
12
+ appendChild(child) {
13
+ this.insertInto(child, null);
14
+ }
15
+ insertBefore(child, ref) {
16
+ this.insertInto(child, ref || null);
17
+ }
18
+ append(...nodes) {
19
+ for (const child of nodes) {
20
+ if (child == null) continue;
21
+ this.appendChild(ChildNode.toNode(this, child));
22
+ }
23
+ }
24
+ prepend(...nodes) {
25
+ const before = this.firstChild;
26
+ for (const child of nodes) {
27
+ if (child == null) continue;
28
+ this.insertBefore(ChildNode.toNode(this, child), before);
29
+ }
30
+ }
31
+ replaceChildren(...nodes) {
32
+ let child;
33
+ while (child = this.firstChild) {
34
+ this.removeChild(child);
35
+ }
36
+ this.append(...nodes);
37
+ }
38
+ removeChild(child) {
39
+ if (child.parentNode !== this) throw Error(`not a child of this node`);
40
+ const prev = child[constants.PREV];
41
+ const next = child[constants.NEXT];
42
+ if (prev) prev[constants.NEXT] = next;else this[constants.CHILD] = next;
43
+ if (next) next[constants.PREV] = prev;
44
+ const childNodes = this.childNodes;
45
+ const childNodesIndex = childNodes.indexOf(child);
46
+ childNodes.splice(childNodesIndex, 1);
47
+ if (child.nodeType === 1) {
48
+ const children = this.children;
49
+ children.splice(children.indexOf(child), 1);
50
+ }
51
+ hooks.hooks.removeChild?.(this, child, childNodesIndex);
52
+ }
53
+ replaceChild(newChild, oldChild) {
54
+ if (oldChild.parentNode !== this) {
55
+ throw Error('reference node is not a child of this parent');
56
+ }
57
+ const next = oldChild[constants.NEXT];
58
+ this.removeChild(oldChild);
59
+ this.insertInto(newChild, next);
60
+ }
61
+ querySelectorAll(selector) {
62
+ return selectors.querySelectorAll(this, selector);
63
+ }
64
+ querySelector(selector) {
65
+ return selectors.querySelector(this, selector);
66
+ }
67
+ insertInto(child, before) {
68
+ // append the children of a DocumentFragment:
69
+ if (child.nodeType === constants.NodeType.DOCUMENT_FRAGMENT_NODE) {
70
+ let node = child[constants.CHILD];
71
+ while (node) {
72
+ const next = node[constants.NEXT];
73
+ this.insertInto(node, before);
74
+ node = next;
75
+ }
76
+ return;
77
+ }
78
+ if (child.parentNode !== null) {
79
+ child.parentNode.removeChild(child);
80
+ }
81
+ if (before) {
82
+ if (before.parentNode !== this) {
83
+ throw Error('reference node is not a child of this parent');
84
+ }
85
+ child[constants.NEXT] = before;
86
+ child[constants.PREV] = before[constants.PREV];
87
+ if (before[constants.PREV] === null) this[constants.CHILD] = child;
88
+ before[constants.PREV] = child;
89
+ } else {
90
+ child[constants.NEXT] = null;
91
+ let last = this[constants.CHILD];
92
+ if (last) {
93
+ let next;
94
+ while (next = last[constants.NEXT]) last = next;
95
+ last[constants.NEXT] = child;
96
+ child[constants.PREV] = last;
97
+ } else {
98
+ this[constants.CHILD] = child;
99
+ child[constants.PREV] = null;
100
+ }
101
+ }
102
+ const ownerDocument = this[constants.OWNER_DOCUMENT];
103
+ const isElement = child.nodeType === constants.NodeType.ELEMENT_NODE;
104
+ child[constants.PARENT] = this;
105
+ child[constants.OWNER_DOCUMENT] = ownerDocument;
106
+ const childNodes = this.childNodes;
107
+ let insertIndex;
108
+ if (before) {
109
+ insertIndex = childNodes.indexOf(before);
110
+ childNodes.splice(insertIndex, 0, child);
111
+ if (isElement) {
112
+ const children = this.children;
113
+ let ref = before;
114
+ while (ref && ref.nodeType !== 1) ref = ref[constants.NEXT];
115
+ if (ref) {
116
+ children.splice(children.indexOf(ref), 0, child);
117
+ } else {
118
+ children.push(child);
119
+ }
120
+ }
121
+ } else {
122
+ insertIndex = childNodes.length;
123
+ childNodes.push(child);
124
+ if (isElement) this.children.push(child);
125
+ }
126
+ hooks.hooks.insertChild?.(this, child, insertIndex);
127
+ }
128
+ }
129
+
130
+ exports.ParentNode = ParentNode;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+ var Element = require('./Element.cjs');
5
+
6
+ class SVGElement extends Element.Element {
7
+ [constants.NS] = constants.NamespaceURI.SVG;
8
+ get ownerSVGElement() {
9
+ let root = null;
10
+ let parent = this.parentNode;
11
+ while (parent instanceof SVGElement) {
12
+ root = parent;
13
+ parent = parent.parentNode;
14
+ }
15
+ return root;
16
+ }
17
+ }
18
+
19
+ exports.SVGElement = SVGElement;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.cjs');
4
+ var CharacterData = require('./CharacterData.cjs');
5
+
6
+ class Text extends CharacterData.CharacterData {
7
+ nodeType = constants.NodeType.TEXT_NODE;
8
+ [constants.NAME] = '#text';
9
+ }
10
+
11
+ exports.Text = Text;
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ var Document = require('./Document.cjs');
4
+ var Event = require('./Event.cjs');
5
+ var EventTarget = require('./EventTarget.cjs');
6
+ var CustomEvent = require('./CustomEvent.cjs');
7
+ var Node = require('./Node.cjs');
8
+ var ParentNode = require('./ParentNode.cjs');
9
+ var ChildNode = require('./ChildNode.cjs');
10
+ var Element = require('./Element.cjs');
11
+ var HTMLElement = require('./HTMLElement.cjs');
12
+ var SVGElement = require('./SVGElement.cjs');
13
+ var CharacterData = require('./CharacterData.cjs');
14
+ var Text = require('./Text.cjs');
15
+ var Comment = require('./Comment.cjs');
16
+ var DocumentFragment = require('./DocumentFragment.cjs');
17
+ var HTMLTemplateElement = require('./HTMLTemplateElement.cjs');
18
+ var CustomElementRegistry = require('./CustomElementRegistry.cjs');
19
+ var MutationObserver = require('./MutationObserver.cjs');
20
+
21
+ class Window extends EventTarget.EventTarget {
22
+ name = '';
23
+ parent = this;
24
+ self = this;
25
+ top = this;
26
+ document = new Document.Document(this);
27
+ customElements = new CustomElementRegistry.CustomElementRegistryImplementation();
28
+ location = globalThis.location;
29
+ navigator = globalThis.navigator;
30
+ Event = Event.Event;
31
+ Node = Node.Node;
32
+ ParentNode = ParentNode.ParentNode;
33
+ ChildNode = ChildNode.ChildNode;
34
+ EventTarget = EventTarget.EventTarget;
35
+ CustomEvent = CustomEvent.CustomEvent;
36
+ DocumentFragment = DocumentFragment.DocumentFragment;
37
+ Document = Document.Document;
38
+ CharacterData = CharacterData.CharacterData;
39
+ Comment = Comment.Comment;
40
+ Text = Text.Text;
41
+ Element = Element.Element;
42
+ HTMLElement = HTMLElement.HTMLElement;
43
+ SVGElement = SVGElement.SVGElement;
44
+ HTMLTemplateElement = HTMLTemplateElement.HTMLTemplateElement;
45
+ MutationObserver = MutationObserver.MutationObserver;
46
+ }
47
+ function installWindowAsGlobal(window) {
48
+ const properties = Object.getOwnPropertyDescriptors(window);
49
+ delete properties.self;
50
+ Object.defineProperties(globalThis, {
51
+ ...properties,
52
+ window: {
53
+ value: window
54
+ }
55
+ });
56
+ if (typeof self === 'undefined') {
57
+ Object.defineProperty(globalThis, 'self', {
58
+ value: window
59
+ });
60
+ } else {
61
+ // There can already be a `self`, like when polyfilling the DOM
62
+ // in a Web Worker. In those cases, just mirror all the `Window`
63
+ // properties onto `self`, rather than wholly redefining it.
64
+ Object.defineProperties(self, properties);
65
+ }
66
+ }
67
+
68
+ exports.Window = Window;
69
+ exports.installWindowAsGlobal = installWindowAsGlobal;
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ const NAME = Symbol('name');
4
+ const VALUE = Symbol('value');
5
+ const NS = Symbol('ns');
6
+ const OWNER_ELEMENT = Symbol('owner');
7
+ const OWNER_DOCUMENT = Symbol('owner_document');
8
+ const ATTRIBUTES = Symbol('attributes');
9
+ const PREV = Symbol('prev');
10
+ const NEXT = Symbol('next');
11
+ const CHILD = Symbol('child');
12
+ const PARENT = Symbol('parent');
13
+ const DATA = Symbol('data');
14
+ const LISTENERS = Symbol('listeners');
15
+ const IS_TRUSTED = Symbol('isTrusted');
16
+ const CONTENT = Symbol('content');
17
+ const SLOT = Symbol('slot');
18
+
19
+ // @TODO remove explicit values
20
+ let NodeType = /*#__PURE__*/function (NodeType) {
21
+ NodeType[NodeType["NODE"] = 0] = "NODE";
22
+ NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE";
23
+ NodeType[NodeType["ATTRIBUTE_NODE"] = 2] = "ATTRIBUTE_NODE";
24
+ NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE";
25
+ NodeType[NodeType["CDATA_SECTION_NODE"] = 4] = "CDATA_SECTION_NODE";
26
+ NodeType[NodeType["ENTITY_REFERENCE_NODE"] = 5] = "ENTITY_REFERENCE_NODE";
27
+ NodeType[NodeType["ENTITY_NODE"] = 6] = "ENTITY_NODE";
28
+ NodeType[NodeType["PROCESSING_INSTRUCTION_NODE"] = 7] = "PROCESSING_INSTRUCTION_NODE";
29
+ NodeType[NodeType["COMMENT_NODE"] = 8] = "COMMENT_NODE";
30
+ NodeType[NodeType["DOCUMENT_NODE"] = 9] = "DOCUMENT_NODE";
31
+ NodeType[NodeType["DOCUMENT_TYPE_NODE"] = 10] = "DOCUMENT_TYPE_NODE";
32
+ NodeType[NodeType["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE";
33
+ return NodeType;
34
+ }({});
35
+ let NamespaceURI = /*#__PURE__*/function (NamespaceURI) {
36
+ NamespaceURI["XHTML"] = "http://www.w3.org/1999/xhtml";
37
+ NamespaceURI["SVG"] = "http://www.w3.org/2000/svg";
38
+ return NamespaceURI;
39
+ }({});
40
+
41
+ exports.ATTRIBUTES = ATTRIBUTES;
42
+ exports.CHILD = CHILD;
43
+ exports.CONTENT = CONTENT;
44
+ exports.DATA = DATA;
45
+ exports.IS_TRUSTED = IS_TRUSTED;
46
+ exports.LISTENERS = LISTENERS;
47
+ exports.NAME = NAME;
48
+ exports.NEXT = NEXT;
49
+ exports.NS = NS;
50
+ exports.NamespaceURI = NamespaceURI;
51
+ exports.NodeType = NodeType;
52
+ exports.OWNER_DOCUMENT = OWNER_DOCUMENT;
53
+ exports.OWNER_ELEMENT = OWNER_ELEMENT;
54
+ exports.PARENT = PARENT;
55
+ exports.PREV = PREV;
56
+ exports.SLOT = SLOT;
57
+ exports.VALUE = VALUE;
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const hooks = {};
4
+
5
+ exports.hooks = hooks;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var hooks = require('./hooks.cjs');
4
+ var Window = require('./Window.cjs');
5
+
6
+
7
+
8
+ exports.hooks = hooks.hooks;
9
+ exports.Window = Window.Window;
10
+ exports.installWindowAsGlobal = Window.installWindowAsGlobal;