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