@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
package/source/EventTarget.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {LISTENERS} from './constants.ts';
|
|
1
|
+
import {HOOKS, LISTENERS, OWNER_DOCUMENT} from './constants.ts';
|
|
3
2
|
import {fireEvent, EventPhase} from './Event.ts';
|
|
4
3
|
import {CAPTURE_MARKER, type Event} from './Event.ts';
|
|
5
4
|
import type {ChildNode} from './ChildNode.ts';
|
|
5
|
+
import type {Document} from './Document.ts';
|
|
6
6
|
|
|
7
7
|
const ONCE_LISTENERS = Symbol('onceListeners');
|
|
8
8
|
|
|
9
9
|
export class EventTarget {
|
|
10
10
|
[LISTENERS]?: Map<string, Set<EventListenerOrEventListenerObject>>;
|
|
11
11
|
[ONCE_LISTENERS]?: WeakMap<EventListenerOrEventListenerObject, EventListener>;
|
|
12
|
+
/**
|
|
13
|
+
* Property set by entities that extend this class that are part of the DOM tree.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
[OWNER_DOCUMENT]?: Document;
|
|
12
17
|
|
|
13
18
|
addEventListener(
|
|
14
19
|
type: string,
|
|
@@ -67,7 +72,12 @@ export class EventTarget {
|
|
|
67
72
|
);
|
|
68
73
|
|
|
69
74
|
list.add(normalizedListener);
|
|
70
|
-
|
|
75
|
+
this[OWNER_DOCUMENT]?.defaultView[HOOKS].addEventListener?.(
|
|
76
|
+
this as any,
|
|
77
|
+
type,
|
|
78
|
+
listener,
|
|
79
|
+
options,
|
|
80
|
+
);
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
removeEventListener(
|
|
@@ -134,7 +144,12 @@ function removeEventListener(
|
|
|
134
144
|
if (list) {
|
|
135
145
|
const deleted = list.delete(normalizedListener);
|
|
136
146
|
if (deleted) {
|
|
137
|
-
|
|
147
|
+
this[OWNER_DOCUMENT]?.defaultView[HOOKS].removeEventListener?.(
|
|
148
|
+
this as any,
|
|
149
|
+
type,
|
|
150
|
+
listener,
|
|
151
|
+
options,
|
|
152
|
+
);
|
|
138
153
|
}
|
|
139
154
|
}
|
|
140
155
|
}
|
package/source/NamedNodeMap.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
CHILD,
|
|
3
|
+
OWNER_ELEMENT,
|
|
4
|
+
NS,
|
|
5
|
+
NEXT,
|
|
6
|
+
NamespaceURI,
|
|
7
|
+
HOOKS,
|
|
8
|
+
} from './constants.ts';
|
|
3
9
|
import type {Attr} from './Attr.ts';
|
|
4
10
|
import type {Element} from './Element.ts';
|
|
5
11
|
|
|
@@ -60,7 +66,11 @@ export class NamedNodeMap {
|
|
|
60
66
|
if (prev) prev[NEXT] = attr[NEXT];
|
|
61
67
|
if (this[CHILD] === attr) this[CHILD] = attr[NEXT];
|
|
62
68
|
updateElementAttribute(ownerElement, attr.name, attr.value, null);
|
|
63
|
-
|
|
69
|
+
ownerElement[HOOKS].removeAttribute?.(
|
|
70
|
+
ownerElement as any,
|
|
71
|
+
name,
|
|
72
|
+
namespaceURI,
|
|
73
|
+
);
|
|
64
74
|
return attr;
|
|
65
75
|
}
|
|
66
76
|
|
|
@@ -108,7 +118,7 @@ export class NamedNodeMap {
|
|
|
108
118
|
attr.value,
|
|
109
119
|
);
|
|
110
120
|
|
|
111
|
-
|
|
121
|
+
ownerElement[HOOKS].setAttribute?.(
|
|
112
122
|
ownerElement as any,
|
|
113
123
|
attr.name,
|
|
114
124
|
attr.value,
|
package/source/Node.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
NEXT,
|
|
8
8
|
NamespaceURI,
|
|
9
9
|
NodeType,
|
|
10
|
+
HOOKS,
|
|
10
11
|
} from './constants.ts';
|
|
11
12
|
import type {Document} from './Document.ts';
|
|
12
13
|
import type {ParentNode} from './ParentNode.ts';
|
|
@@ -28,6 +29,10 @@ export class Node extends EventTarget {
|
|
|
28
29
|
[PREV]: Node | null = null;
|
|
29
30
|
[NEXT]: Node | null = null;
|
|
30
31
|
|
|
32
|
+
protected get [HOOKS]() {
|
|
33
|
+
return this[OWNER_DOCUMENT].defaultView[HOOKS];
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
get localName() {
|
|
32
37
|
return this[NAME];
|
|
33
38
|
}
|
package/source/ParentNode.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {hooks} from './hooks.ts';
|
|
2
1
|
import {
|
|
3
2
|
CHILD,
|
|
4
3
|
NEXT,
|
|
@@ -6,6 +5,7 @@ import {
|
|
|
6
5
|
PARENT,
|
|
7
6
|
OWNER_DOCUMENT,
|
|
8
7
|
NodeType,
|
|
8
|
+
HOOKS,
|
|
9
9
|
} from './constants.ts';
|
|
10
10
|
import type {Node} from './Node.ts';
|
|
11
11
|
import {ChildNode, toNode} from './ChildNode.ts';
|
|
@@ -66,7 +66,7 @@ export class ParentNode extends ChildNode {
|
|
|
66
66
|
children.splice(children.indexOf(child), 1);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
this[HOOKS].removeChild?.(this as any, child as any, childNodesIndex);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
replaceChild(newChild: Node, oldChild: Node) {
|
|
@@ -153,6 +153,6 @@ export class ParentNode extends ChildNode {
|
|
|
153
153
|
if (isElement) this.children.push(child);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
this[HOOKS].insertChild?.(this as any, child as any, insertIndex);
|
|
157
157
|
}
|
|
158
158
|
}
|
package/source/Window.ts
CHANGED
|
@@ -15,8 +15,11 @@ import {DocumentFragment} from './DocumentFragment.ts';
|
|
|
15
15
|
import {HTMLTemplateElement} from './HTMLTemplateElement.ts';
|
|
16
16
|
import {CustomElementRegistryImplementation} from './CustomElementRegistry.ts';
|
|
17
17
|
import {MutationObserver} from './MutationObserver.ts';
|
|
18
|
+
import {HOOKS} from './constants.ts';
|
|
19
|
+
import type {Hooks} from './hooks.ts';
|
|
18
20
|
|
|
19
21
|
export class Window extends EventTarget {
|
|
22
|
+
[HOOKS]: Partial<Hooks> = {};
|
|
20
23
|
name = '';
|
|
21
24
|
parent = this;
|
|
22
25
|
self = this;
|
package/source/constants.ts
CHANGED
|
@@ -14,6 +14,7 @@ export const LISTENERS = Symbol('listeners');
|
|
|
14
14
|
export const IS_TRUSTED = Symbol('isTrusted');
|
|
15
15
|
export const CONTENT = Symbol('content');
|
|
16
16
|
export const SLOT = Symbol('slot');
|
|
17
|
+
export const HOOKS = Symbol('hooks');
|
|
17
18
|
|
|
18
19
|
// @TODO remove explicit values
|
|
19
20
|
export const enum NodeType {
|
package/source/hooks.ts
CHANGED
package/source/index.ts
CHANGED
package/build/esm/hooks.mjs
DELETED