@verajs/ssr 0.2.0 → 0.3.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/README.md +510 -373
- package/dist/vera/diagnostics.d.ts +20 -0
- package/dist/vera/diagnostics.js +98 -0
- package/dist/vera/escaping.d.ts +142 -0
- package/dist/vera/escaping.js +267 -0
- package/dist/vera/events.d.ts +41 -0
- package/dist/vera/events.js +162 -0
- package/dist/vera/frames.d.ts +38 -0
- package/dist/vera/frames.js +195 -0
- package/dist/vera/index.d.ts +48 -0
- package/dist/vera/index.js +480 -0
- package/{types → dist/vera}/nodes.d.ts +397 -300
- package/dist/vera/nodes.js +2322 -0
- package/dist/vera/parse.d.ts +37 -0
- package/dist/vera/parse.js +390 -0
- package/dist/vera/reflections.d.ts +566 -0
- package/dist/vera/reflections.js +820 -0
- package/dist/vera/registry.d.ts +14 -0
- package/{src → dist}/vera/registry.js +5 -1
- package/dist/vera/report.d.ts +27 -0
- package/dist/vera/report.js +56 -0
- package/dist/vera/scan.d.ts +37 -0
- package/dist/vera/scan.js +143 -0
- package/dist/vera/select.d.ts +40 -0
- package/dist/vera/select.js +261 -0
- package/dist/vera/serializer.d.ts +39 -0
- package/dist/vera/serializer.js +1372 -0
- package/dist/vera/shim.d.ts +42 -0
- package/dist/vera/shim.js +853 -0
- package/dist/vera/slots.d.ts +5 -0
- package/dist/vera/slots.js +104 -0
- package/dist/vera/stylesheets.d.ts +62 -0
- package/dist/vera/stylesheets.js +180 -0
- package/dist/vera/tokenizer.d.ts +32 -0
- package/dist/vera/tokenizer.js +528 -0
- package/dist/vera/types.d.ts +117 -0
- package/dist/vera/views.d.ts +63 -0
- package/dist/vera/views.js +245 -0
- package/package.json +12 -13
- package/src/vera/escaping.js +0 -135
- package/src/vera/events.js +0 -164
- package/src/vera/frames.js +0 -102
- package/src/vera/index.js +0 -1171
- package/src/vera/nodes.js +0 -2270
- package/src/vera/parse.js +0 -381
- package/src/vera/reflections.js +0 -811
- package/src/vera/select.js +0 -234
- package/src/vera/serializer.js +0 -928
- package/src/vera/shim.js +0 -761
- package/src/vera/stylesheets.js +0 -155
- package/src/vera/views.js +0 -240
- package/types/escaping.d.ts +0 -27
- package/types/events.d.ts +0 -4
- package/types/frames.d.ts +0 -12
- package/types/index.d.ts +0 -13
- package/types/parse.d.ts +0 -19
- package/types/reflections.d.ts +0 -657
- package/types/registry.d.ts +0 -8
- package/types/select.d.ts +0 -5
- package/types/serializer.d.ts +0 -26
- package/types/shim.d.ts +0 -23
- package/types/stylesheets.d.ts +0 -53
- package/types/views.d.ts +0 -26
|
@@ -1,51 +1,236 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { datasetView, styleView, tokenListView } from './views.js';
|
|
2
|
+
import { StyleSheetShim } from './stylesheets.js';
|
|
3
|
+
/** A retained child: an element, a text node or a comment — the nodes a container keeps by reference. */
|
|
4
|
+
type ChildShim = ElementShim | TextShim | CommentShim;
|
|
5
|
+
/** One of a container's children: a retained node, or a chunk of markup held as a string. */
|
|
6
|
+
type EntryShim = string | ChildShim;
|
|
7
|
+
/** Any node of this DOM: a container (element, shadow root, fragment), a text node or a comment. */
|
|
8
|
+
type NodeShim = ContainerShim | TextShim | CommentShim;
|
|
9
|
+
/** What a `CharacterDataShim` always is: the base is never instantiated on its own. */
|
|
10
|
+
type CharacterShim = TextShim | CommentShim;
|
|
11
|
+
/**
|
|
12
|
+
* What the insertion methods take: a node to retain, or a fragment (or shadow root) whose children move
|
|
13
|
+
* in. Anything else reaches only the foreign-object fallback, which keeps its `innerHTML`.
|
|
14
|
+
*/
|
|
15
|
+
type InsertableShim = ChildShim | FragmentShim | ShadowRootShim;
|
|
16
|
+
/**
|
|
17
|
+
* A node read by duck typing, the way this file's feature checks read one — `node.openTag` to ask "is
|
|
18
|
+
* this an element", `node.nodeType` to ask which kind it is. Every member is optional, because
|
|
19
|
+
* whether it is there is the question being asked.
|
|
20
|
+
*/
|
|
21
|
+
type DuckNode = {
|
|
22
|
+
readonly nodeType?: number;
|
|
23
|
+
readonly nodeName?: string;
|
|
24
|
+
readonly localName?: string;
|
|
25
|
+
readonly _attributes?: Map<string, string>;
|
|
26
|
+
readonly openTag?: () => string;
|
|
27
|
+
readonly innerHTML?: string;
|
|
28
|
+
readonly _rendered?: boolean;
|
|
29
|
+
};
|
|
30
|
+
/** The options a shadow root is opened with. `mode` is checked by `attachShadow`, not by the type. */
|
|
31
|
+
type ShadowInit = {
|
|
32
|
+
mode?: ShadowRootMode;
|
|
33
|
+
delegatesFocus?: boolean;
|
|
34
|
+
clonable?: boolean;
|
|
35
|
+
serializable?: boolean;
|
|
36
|
+
slotAssignment?: SlotAssignmentMode;
|
|
37
|
+
};
|
|
38
|
+
/** An attribute node as `getAttributeNode` answers and `setAttributeNode` takes one. */
|
|
39
|
+
type AttributeNodeShim = {
|
|
40
|
+
name: string;
|
|
41
|
+
value: unknown;
|
|
42
|
+
};
|
|
43
|
+
/** What `attachInternals` hands back: inert, because none of what internals carry reaches markup. */
|
|
44
|
+
type InternalsShim = {
|
|
45
|
+
shadowRoot: ShadowRootShim | null;
|
|
46
|
+
form: null;
|
|
47
|
+
labels: ElementShim[];
|
|
48
|
+
willValidate: boolean;
|
|
49
|
+
validity: {
|
|
50
|
+
valid: boolean;
|
|
51
|
+
};
|
|
52
|
+
validationMessage: string;
|
|
53
|
+
states: Set<string>;
|
|
54
|
+
setFormValue: () => void;
|
|
55
|
+
setValidity: () => void;
|
|
56
|
+
checkValidity: () => boolean;
|
|
57
|
+
reportValidity: () => boolean;
|
|
58
|
+
};
|
|
59
|
+
/** An attribute as `attributes` lists it. */
|
|
60
|
+
type AttributeShim = {
|
|
61
|
+
name: string;
|
|
62
|
+
value: string;
|
|
63
|
+
localName: string;
|
|
64
|
+
namespaceURI: null;
|
|
65
|
+
ownerElement: ElementShim;
|
|
66
|
+
};
|
|
67
|
+
/** `attributes`: an array of the attributes, carrying `NamedNodeMap`'s own methods. */
|
|
68
|
+
interface NamedNodeMapShim extends Array<AttributeShim> {
|
|
69
|
+
getNamedItem(name: string): AttributeShim | null;
|
|
70
|
+
getNamedItemNS(namespace: string | null, name: string): AttributeShim | null;
|
|
71
|
+
item(index: number): AttributeShim | null;
|
|
72
|
+
setNamedItem(attribute: AttributeNodeShim): AttributeShim | null;
|
|
73
|
+
removeNamedItem(name: string): AttributeShim;
|
|
74
|
+
}
|
|
75
|
+
/** `childNodes`, `children` and the query results: an array, with `item()` and `namedItem()` on it. */
|
|
76
|
+
interface CollectionShim<T> extends Array<T> {
|
|
77
|
+
item(index: number): T | null;
|
|
78
|
+
namedItem(name: string): T | null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* What an element and a shadow root both are: something that holds children as markup and can be
|
|
82
|
+
* appended to, queried and listened to.
|
|
83
|
+
*
|
|
84
|
+
* Shared because they kept drifting. `ShadowRootShim` was built for the renderer and `ElementShim`
|
|
85
|
+
* for core, so each was short of a different set of members — the router threw on
|
|
86
|
+
* `shadowRoot.addEventListener`, component code threw on `element.dataset`, and every gap was found
|
|
87
|
+
* by probing rather than by the two being one thing. Anything a container does belongs here.
|
|
88
|
+
*
|
|
89
|
+
* Queries answer emptily because this holds a **string**, not a tree; nothing in this package parses
|
|
90
|
+
* HTML. `insertBefore` and `cloneNode` are deliberately absent for the same reason — they need a
|
|
91
|
+
* tree, and faking them would misplace content silently.
|
|
92
|
+
*
|
|
93
|
+
* Events come from Node's own `EventTarget`, so `once`, `handleEvent`, `event.target`,
|
|
94
|
+
* `stopImmediatePropagation` and the return value of `dispatchEvent` are all correct without this
|
|
95
|
+
* package implementing any of them. They used to be no-ops that reported every event delivered, so
|
|
96
|
+
* anything a component decided from its own event — a control reading back its change, a callback
|
|
97
|
+
* dispatched at mount, a `preventDefault` deciding whether to proceed — took one branch here and
|
|
98
|
+
* the other in a browser. **Bubbling is still absent**: with children held as a string there is no
|
|
99
|
+
* ancestor chain to walk, so an event reaches its own element's listeners and stops.
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* One entry's markup. A retained node serializes itself **at output time**, which is the entire
|
|
103
|
+
* point of keeping it: a mutation made after `appendChild` is still on the node when this runs.
|
|
104
|
+
* The expression is the one `appendChild` used to inline, unchanged, so the bytes are identical.
|
|
105
|
+
*/
|
|
106
|
+
export declare const serializeElement: (element: ElementShim) => string;
|
|
107
|
+
/** For the server's distributor (`slots.ts`) — an alias, so this module's own reads stay module-local. */
|
|
108
|
+
export declare const slotName: (node: ChildShim) => string | null;
|
|
109
|
+
/**
|
|
110
|
+
* **Text and comments are nodes.**
|
|
111
|
+
*
|
|
112
|
+
* They were not: `createTextNode` returned an object literal with an `innerHTML` string, so it had
|
|
113
|
+
* no identity, no parent and no `nodeType`, and appending one inlined its markup and lost the node.
|
|
114
|
+
* `childNodes` therefore reported `1` for `text <b>bold</b> tail`, where every browser says `3`.
|
|
115
|
+
*
|
|
116
|
+
* Like an element, a parsed one keeps **the exact bytes it came from** so re-serializing reproduces
|
|
117
|
+
* the input — `&` stays `&` rather than becoming this package's `&` — and falls back to
|
|
118
|
+
* escaping its data the moment somebody writes to it.
|
|
119
|
+
*/
|
|
120
|
+
/**
|
|
121
|
+
* **`Node` itself — the one base every node of this DOM shares** (2026-10-09). Text and comments were a separate
|
|
122
|
+
* line from containers, and `Node` was the container class, so `text instanceof Node` answered `false` where every
|
|
123
|
+
* engine answers `true`, and a Node-typed parameter could not tell a node from any object: `appendChild({})` and
|
|
124
|
+
* `replaceChild({}, child)` were accepted, `contains({})` answered `false`, `removeChild(null)` threw the wrong class.
|
|
125
|
+
* Measured by differential against jsdom (tests/ssr-imitations-differential).
|
|
126
|
+
*/
|
|
127
|
+
export declare class NodeBaseShim extends EventTarget {
|
|
128
|
+
constructor();
|
|
129
|
+
}
|
|
130
|
+
/** The token this DOM's own creation paths hand `ElementShim` — see its constructor. Module-local, so it cannot be forged. */
|
|
131
|
+
declare const MADE: unique symbol;
|
|
132
|
+
export declare class CharacterDataShim extends NodeBaseShim {
|
|
133
|
+
_data: string;
|
|
134
|
+
/** The bytes a parsed node came from, until something writes to it. */
|
|
135
|
+
_source: string | null;
|
|
136
|
+
_parent: ContainerShim | null;
|
|
137
|
+
isConnected: boolean;
|
|
138
|
+
constructor(data: unknown);
|
|
139
|
+
/** Registered here rather than on the platform's `EventTarget`; see `events.js`. */
|
|
140
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
|
|
141
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
|
|
142
|
+
dispatchEvent(event: Event): boolean;
|
|
143
|
+
get data(): string;
|
|
144
|
+
set data(value: unknown);
|
|
145
|
+
get nodeValue(): unknown;
|
|
146
|
+
set nodeValue(value: unknown);
|
|
147
|
+
get textContent(): string;
|
|
148
|
+
set textContent(value: unknown);
|
|
149
|
+
get length(): number;
|
|
150
|
+
get parentNode(): ContainerShim | null;
|
|
151
|
+
get parentElement(): ElementShim | null;
|
|
152
|
+
get childNodes(): ChildShim[];
|
|
153
|
+
get firstChild(): null;
|
|
154
|
+
get lastChild(): null;
|
|
155
|
+
hasChildNodes(): boolean;
|
|
156
|
+
get ownerDocument(): Document;
|
|
157
|
+
get nextSibling(): ChildShim | null;
|
|
158
|
+
get previousSibling(): ChildShim | null;
|
|
159
|
+
_siblingAt(step: number, view?: (container: ContainerShim) => ChildShim[]): ChildShim | null;
|
|
160
|
+
remove(this: CharacterShim): void;
|
|
161
|
+
before(...nodes: Array<string | InsertableShim>): void;
|
|
162
|
+
after(...nodes: Array<string | InsertableShim>): void;
|
|
163
|
+
replaceWith(...nodes: Array<string | InsertableShim>): void;
|
|
164
|
+
isSameNode(node: unknown): boolean;
|
|
165
|
+
isEqualNode(node: {
|
|
166
|
+
readonly nodeType?: number;
|
|
167
|
+
readonly data?: unknown;
|
|
168
|
+
} | null | undefined): boolean;
|
|
169
|
+
contains(node: unknown): boolean;
|
|
170
|
+
getRootNode(): CharacterDataShim | ContainerShim;
|
|
171
|
+
appendData(value: unknown): void;
|
|
172
|
+
substringData(offset: number, count: number): string;
|
|
173
|
+
}
|
|
174
|
+
export declare class TextShim extends CharacterDataShim {
|
|
175
|
+
get nodeType(): 3;
|
|
176
|
+
get nodeName(): '#text';
|
|
5
177
|
get wholeText(): string;
|
|
178
|
+
/**
|
|
179
|
+
* **A text node is written by its PARENT's rule — the platform's serialization rule, and the one place this DOM
|
|
180
|
+
* decides it.** Inside `<style>`/`<script>` it is raw, with only the element's own end tag neutralized
|
|
181
|
+
* (`escapeRawText`); everywhere else, `<textarea>` and `<title>` included, it is escaped. Untouched parsed text keeps
|
|
182
|
+
* the bytes it came from. Raw-text content used to be stored as MARKUP by `textContent`/`value`, which nothing then
|
|
183
|
+
* escaped: `textarea.value = '</textarea><img onerror=…>'` closed the element and served the `<img>`.
|
|
184
|
+
*/
|
|
6
185
|
markup(): string;
|
|
7
186
|
cloneNode(): TextShim;
|
|
8
187
|
/** Splits at `offset`, leaving this node with the first half and inserting the second after it. */
|
|
9
|
-
splitText(offset:
|
|
188
|
+
splitText(offset: number): TextShim;
|
|
10
189
|
}
|
|
11
|
-
export class CommentShim extends CharacterDataShim {
|
|
12
|
-
get nodeType():
|
|
13
|
-
get nodeName():
|
|
190
|
+
export declare class CommentShim extends CharacterDataShim {
|
|
191
|
+
get nodeType(): 8;
|
|
192
|
+
get nodeName(): '#comment';
|
|
14
193
|
markup(): string;
|
|
15
194
|
cloneNode(): CommentShim;
|
|
16
195
|
}
|
|
17
|
-
export class ContainerShim extends
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* raw markup. Serialisation happens when `innerHTML` is *read*, not when a child is appended —
|
|
21
|
-
* appending used to serialise immediately and drop the node, so `appendChild(kid)` followed by
|
|
22
|
-
* `kid.textContent = 'x'` rendered `<b></b>` and lost the text with no diagnostic.
|
|
23
|
-
*/
|
|
24
|
-
_entries: any[];
|
|
25
|
-
_parent: any;
|
|
26
|
-
/** A server-rendered node is in the document being built, so it is connected. */
|
|
196
|
+
export declare class ContainerShim extends NodeBaseShim {
|
|
197
|
+
_entries: EntryShim[];
|
|
198
|
+
_parent: ContainerShim | null;
|
|
27
199
|
isConnected: boolean;
|
|
200
|
+
/** Whether the markup chunks have been looked at; see `parseChunks`. */
|
|
201
|
+
_parsed?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* A shadow root's host. Declared on the base because any chain's root is read for it — only
|
|
204
|
+
* `ShadowRootShim` sets it, and on every other container it is absent.
|
|
205
|
+
*/
|
|
206
|
+
_host?: ElementShim | null;
|
|
207
|
+
constructor();
|
|
208
|
+
/** Registered here rather than on the platform's `EventTarget`; see `events.js`. */
|
|
209
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
|
|
210
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
|
|
211
|
+
dispatchEvent(event: Event): boolean;
|
|
212
|
+
get innerHTML(): string;
|
|
213
|
+
set innerHTML(markup: unknown);
|
|
214
|
+
/** Children replaced by one text node holding `data` — none for `''`, as `textContent` does. */
|
|
215
|
+
_replaceWithText(data: string): void;
|
|
28
216
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
217
|
+
* **Every insertion path places its nodes here, at `at`, replacing `replace` entries** — `appendChild`,
|
|
218
|
+
* `insertBefore` and `replaceChild` (and everything that routes through them: `before`, `after`, `replaceWith`,
|
|
219
|
+
* `prepend`, `append`). They each kept their own copy, and only `appendChild`'s knew that a FRAGMENT hands over its
|
|
220
|
+
* children and is left empty: `insertBefore` and `replaceChild` inserted a fragment as its markup, so the children
|
|
221
|
+
* never arrived where a browser puts them and the fragment still reported having them. And none of them noticed
|
|
222
|
+
* markup TEXT arriving after this container had been parsed, so a query never saw it: inserting text resets `_parsed`.
|
|
223
|
+
* The caller has already detached `node` from any parent.
|
|
31
224
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
override removeEventListener(type: any, callback: any, options: any): void;
|
|
35
|
-
/** @override */
|
|
36
|
-
override dispatchEvent(event: any): boolean;
|
|
37
|
-
set innerHTML(markup: string);
|
|
38
|
-
get innerHTML(): string;
|
|
39
|
-
/** New markup has not been looked at yet, whatever was true of the markup it replaced. */
|
|
40
|
-
_parsed: boolean | undefined;
|
|
41
|
-
appendChild(node: any): any;
|
|
225
|
+
_place(node: InsertableShim, at: number, replace: number): void;
|
|
226
|
+
appendChild<T extends InsertableShim>(node: T): T;
|
|
42
227
|
/**
|
|
43
228
|
* **Position a node among the children**, which needed a tree and now has one. `reference` of
|
|
44
229
|
* `null` appends, as the platform says, and a reference that is not a child is a `NotFoundError`
|
|
45
230
|
* rather than a silent append — the difference between "put it at the end" and "you asked about
|
|
46
231
|
* a node I do not have" is exactly the kind of thing a server should not paper over.
|
|
47
232
|
*/
|
|
48
|
-
insertBefore(node:
|
|
233
|
+
insertBefore<T extends InsertableShim>(node: T, reference: ChildShim | null | undefined): T;
|
|
49
234
|
/**
|
|
50
235
|
* **`moveBefore` is `insertBefore` with a precondition**: the node must already have a parent.
|
|
51
236
|
* Measured on Chromium and Firefox, which agree on all of it (WebKit does not implement it yet):
|
|
@@ -57,21 +242,21 @@ export class ContainerShim extends EventTarget {
|
|
|
57
242
|
* state to preserve on a server, so this is a move; having it means code written for the browser
|
|
58
243
|
* runs here rather than hitting a missing method.
|
|
59
244
|
*/
|
|
60
|
-
moveBefore(node:
|
|
61
|
-
replaceChild(node:
|
|
245
|
+
moveBefore<T extends InsertableShim>(node: T, reference: ChildShim | null | undefined): T;
|
|
246
|
+
replaceChild(node: InsertableShim, old: ChildShim): ChildShim;
|
|
62
247
|
/**
|
|
63
248
|
* **Where each node sits relative to another**, as the spec's bit field. Two nodes with no common
|
|
64
249
|
* root are `DISCONNECTED | IMPLEMENTATION_SPECIFIC` plus a direction the spec leaves to the
|
|
65
250
|
* implementation, so only the disconnected bit is worth comparing across implementations.
|
|
66
251
|
*/
|
|
67
|
-
compareDocumentPosition(other:
|
|
252
|
+
compareDocumentPosition(other: NodeShim): number;
|
|
68
253
|
/** Remove a node from this container's entries without touching its own parent pointer. */
|
|
69
|
-
_detach(node:
|
|
254
|
+
_detach(node: ChildShim): void;
|
|
70
255
|
/**
|
|
71
256
|
* **Absent until nodes were retained**, so `host.removeChild(kid)` was a `TypeError` — there was
|
|
72
257
|
* nothing to remove, the child having been flattened into a string at append time.
|
|
73
258
|
*/
|
|
74
|
-
removeChild(node:
|
|
259
|
+
removeChild<T extends ChildShim>(node: T): T;
|
|
75
260
|
/**
|
|
76
261
|
* What a node with no tree above or below it answers — shared, because an element and a shadow
|
|
77
262
|
* root answer these identically and two copies is how they came to disagree in the first place.
|
|
@@ -81,30 +266,31 @@ export class ContainerShim extends EventTarget {
|
|
|
81
266
|
* *absence* was a `TypeError` that took the whole render down — `this.parentElement && …` is
|
|
82
267
|
* ordinary defensive code and it crashed.
|
|
83
268
|
*/
|
|
84
|
-
get parentNode():
|
|
269
|
+
get parentNode(): ContainerShim | null;
|
|
85
270
|
/** `null` when the parent is not an element — a shadow root is a parent and not an element. */
|
|
86
|
-
get parentElement():
|
|
87
|
-
get firstChild():
|
|
88
|
-
get lastChild():
|
|
89
|
-
get lastElementChild():
|
|
271
|
+
get parentElement(): ElementShim | null;
|
|
272
|
+
get firstChild(): ChildShim | null;
|
|
273
|
+
get lastChild(): ChildShim | null;
|
|
274
|
+
get lastElementChild(): ElementShim | null;
|
|
90
275
|
/**
|
|
91
276
|
* **The siblings are real now.** These answered `null` unconditionally, which was truthful while a
|
|
92
277
|
* child was flattened into its parent's markup and became a lie the moment nodes were retained —
|
|
93
278
|
* `element.nextSibling` on the middle of three children reported nothing at all. There are no text
|
|
94
279
|
* nodes in this DOM, so the element-wise and node-wise spellings answer the same list.
|
|
95
280
|
*/
|
|
96
|
-
get nextSibling():
|
|
97
|
-
get previousSibling():
|
|
98
|
-
get nextElementSibling():
|
|
99
|
-
get previousElementSibling():
|
|
100
|
-
/**
|
|
101
|
-
_siblingAt(step: number
|
|
281
|
+
get nextSibling(): ChildShim | null;
|
|
282
|
+
get previousSibling(): ChildShim | null;
|
|
283
|
+
get nextElementSibling(): ElementShim | null;
|
|
284
|
+
get previousElementSibling(): ElementShim | null;
|
|
285
|
+
/** Node-wise by default; handed `elementsOf`, it steps over everything that is not an element. */
|
|
286
|
+
_siblingAt(step: number): ChildShim | null;
|
|
287
|
+
_siblingAt(step: number, view: (container: ContainerShim) => ElementShim[]): ElementShim | null;
|
|
102
288
|
/**
|
|
103
289
|
* **The slot this node is projected into**, which needs the host's shadow root and the node's own
|
|
104
290
|
* `slot` name — both of which are here. It answered `null` for every node, so a component asking
|
|
105
291
|
* where its light DOM had landed was told "nowhere".
|
|
106
292
|
*/
|
|
107
|
-
get assignedSlot():
|
|
293
|
+
get assignedSlot(): ElementShim | null;
|
|
108
294
|
get offsetParent(): null;
|
|
109
295
|
get childElementCount(): number;
|
|
110
296
|
hasChildNodes(): boolean;
|
|
@@ -112,24 +298,25 @@ export class ContainerShim extends EventTarget {
|
|
|
112
298
|
get baseURI(): string;
|
|
113
299
|
get namespaceURI(): string;
|
|
114
300
|
get prefix(): null;
|
|
115
|
-
|
|
301
|
+
/** `null` before the environment exists, as its twin on the other node classes already answers. */
|
|
302
|
+
get ownerDocument(): Document | null;
|
|
116
303
|
/**
|
|
117
304
|
* **Walks the parent chain**, as the platform does. It compared identity only, so
|
|
118
305
|
* `host.contains(child)` was `false` for a child the host plainly held — ordinary defensive code
|
|
119
306
|
* reading as "this is not mine".
|
|
120
307
|
*/
|
|
121
|
-
contains(node:
|
|
308
|
+
contains(node: NodeShim | null | undefined): boolean;
|
|
122
309
|
/** The `ChildNode` trio, shared with text and comments through `insertAround`. */
|
|
123
|
-
before(...nodes:
|
|
124
|
-
after(...nodes:
|
|
125
|
-
replaceWith(...nodes:
|
|
126
|
-
isSameNode(node:
|
|
310
|
+
before(...nodes: Array<string | InsertableShim>): void;
|
|
311
|
+
after(...nodes: Array<string | InsertableShim>): void;
|
|
312
|
+
replaceWith(...nodes: Array<string | InsertableShim>): void;
|
|
313
|
+
isSameNode(node: unknown): boolean;
|
|
127
314
|
/**
|
|
128
315
|
* **Structural equality, not identity** — that is what `isSameNode` is for, and this answered the
|
|
129
316
|
* same thing, so two elements built identically reported themselves different. The spec compares
|
|
130
317
|
* type, name, attributes as a set, and children pairwise.
|
|
131
318
|
*/
|
|
132
|
-
isEqualNode(node:
|
|
319
|
+
isEqualNode(node: DuckNode | null | undefined): boolean;
|
|
133
320
|
/**
|
|
134
321
|
* **Merges adjacent text and drops the empty**, which is what it is for. It was a no-op because
|
|
135
322
|
* there were no text nodes to merge — appending two of them left two entries a browser would have
|
|
@@ -140,10 +327,12 @@ export class ContainerShim extends EventTarget {
|
|
|
140
327
|
* The furthest ancestor, which is the shadow root for anything a component rendered into one —
|
|
141
328
|
* unless `composed` is asked for, which keeps going out through the root's host as a browser does.
|
|
142
329
|
*/
|
|
143
|
-
getRootNode(options
|
|
330
|
+
getRootNode(options?: {
|
|
331
|
+
composed?: boolean;
|
|
332
|
+
}): ContainerShim;
|
|
144
333
|
/** Needs layout, which a string does not have; a browser with no box returns nothing either. */
|
|
145
334
|
elementFromPoint(): null;
|
|
146
|
-
elementsFromPoint():
|
|
335
|
+
elementsFromPoint(): ElementShim[];
|
|
147
336
|
getSelection(): null;
|
|
148
337
|
/** `append` takes several nodes, and strings as text — the modern spelling of `appendChild`. */
|
|
149
338
|
/**
|
|
@@ -151,8 +340,8 @@ export class ContainerShim extends EventTarget {
|
|
|
151
340
|
* now reads every retained node back into text and writes it as one chunk — flattening the tree
|
|
152
341
|
* this class exists to keep. Pushing the chunk is the same bytes and keeps the nodes.
|
|
153
342
|
*/
|
|
154
|
-
append(...nodes:
|
|
155
|
-
replaceChildren(...nodes:
|
|
343
|
+
append(...nodes: Array<string | InsertableShim>): void;
|
|
344
|
+
replaceChildren(...nodes: Array<string | InsertableShim>): void;
|
|
156
345
|
/** Splices the entries rather than concatenating markup, for the reason `append` gives. */
|
|
157
346
|
/**
|
|
158
347
|
* **The restore has to survive a throw.** `append` can reject a node — an ancestor of `this` is a
|
|
@@ -171,24 +360,24 @@ export class ContainerShim extends EventTarget {
|
|
|
171
360
|
* Found by fuzzing sequences of tree mutations against jsdom; the failing sequence ended
|
|
172
361
|
* `prepend(n1, root)` and the loss showed up as a missing text node four operations later.
|
|
173
362
|
*/
|
|
174
|
-
prepend(...nodes:
|
|
363
|
+
prepend(...nodes: Array<string | InsertableShim>): void;
|
|
175
364
|
/**
|
|
176
365
|
* **Answers from the node view**, which markup assigned as a string now has. Every query used to
|
|
177
366
|
* return nothing whatever was asked, so a component branched the wrong way with nothing said.
|
|
178
367
|
* A selector this DOM cannot answer honestly throws rather than answering `null` — see
|
|
179
368
|
* `select.js`.
|
|
180
369
|
*/
|
|
181
|
-
querySelector(selector:
|
|
182
|
-
querySelectorAll(selector:
|
|
183
|
-
getElementById(id:
|
|
370
|
+
querySelector(selector: string): ElementShim | null;
|
|
371
|
+
querySelectorAll(selector: string): CollectionShim<ElementShim>;
|
|
372
|
+
getElementById(id: string): ElementShim | null;
|
|
184
373
|
/**
|
|
185
374
|
* **Only retained nodes.** Every entry this DOM holds as an element *is* an element, so `children`
|
|
186
375
|
* and `childNodes` answer the same list — there are no text nodes to separate them, and markup
|
|
187
376
|
* kept as a string is not nodes at all (`nodesOf` says so).
|
|
188
377
|
*/
|
|
189
|
-
get children():
|
|
190
|
-
get childNodes():
|
|
191
|
-
get firstElementChild():
|
|
378
|
+
get children(): CollectionShim<ElementShim>;
|
|
379
|
+
get childNodes(): CollectionShim<ChildShim>;
|
|
380
|
+
get firstElementChild(): ElementShim | null;
|
|
192
381
|
}
|
|
193
382
|
/**
|
|
194
383
|
* A fragment is a container and nothing more.
|
|
@@ -197,21 +386,30 @@ export class ContainerShim extends EventTarget {
|
|
|
197
386
|
* for an element — a check the renderer makes, and one that a shared class would have made true for
|
|
198
387
|
* everything.
|
|
199
388
|
*/
|
|
200
|
-
export class FragmentShim extends ContainerShim {
|
|
201
|
-
get nodeType():
|
|
202
|
-
get nodeName():
|
|
389
|
+
export declare class FragmentShim extends ContainerShim {
|
|
390
|
+
get nodeType(): 11;
|
|
391
|
+
get nodeName(): '#document-fragment';
|
|
203
392
|
}
|
|
204
|
-
export class ShadowRootShim extends ContainerShim {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
|
|
210
|
-
|
|
393
|
+
export declare class ShadowRootShim extends ContainerShim {
|
|
394
|
+
mode: ShadowRootMode;
|
|
395
|
+
_init: ShadowInit;
|
|
396
|
+
_host: ElementShim | null;
|
|
397
|
+
/** The text of the `<style>` elements appended here. */
|
|
398
|
+
_styles: string[];
|
|
399
|
+
_adopted?: StyleSheetShim[];
|
|
400
|
+
constructor(init: ShadowInit);
|
|
211
401
|
/** `shadowrootmode` plus whatever else the root was opened with, as the parser expects them. */
|
|
212
402
|
templateAttributes(): string;
|
|
403
|
+
/**
|
|
404
|
+
* A `<style>` joins the stylesheet collection; anything else is content.
|
|
405
|
+
*
|
|
406
|
+
* Every append used to be treated as a stylesheet, on the assumption that only `adoptStyles`
|
|
407
|
+
* would ever reach here. A component appending an element to its own shadow root — ordinary DOM
|
|
408
|
+
* code — therefore had that element silently turned into CSS and its markup lost.
|
|
409
|
+
*/
|
|
410
|
+
appendChild<T extends InsertableShim>(node: T): T;
|
|
213
411
|
/** A shadow root's `host` is part of the contract `@verajs/router` reads. */
|
|
214
|
-
get host():
|
|
412
|
+
get host(): ElementShim | null;
|
|
215
413
|
/**
|
|
216
414
|
* The options it was opened with, readable the way a browser exposes them.
|
|
217
415
|
*
|
|
@@ -222,21 +420,19 @@ export class ShadowRootShim extends ContainerShim {
|
|
|
222
420
|
get delegatesFocus(): boolean;
|
|
223
421
|
get clonable(): boolean;
|
|
224
422
|
get serializable(): boolean;
|
|
225
|
-
get slotAssignment():
|
|
226
|
-
get nodeType():
|
|
227
|
-
get nodeName():
|
|
423
|
+
get slotAssignment(): SlotAssignmentMode;
|
|
424
|
+
get nodeType(): 11;
|
|
425
|
+
get nodeName(): '#document-fragment';
|
|
228
426
|
/** Nothing is focused on a server, and nothing is in a top layer. */
|
|
229
427
|
get activeElement(): null;
|
|
230
428
|
get fullscreenElement(): null;
|
|
231
429
|
get pointerLockElement(): null;
|
|
232
430
|
get pictureInPictureElement(): null;
|
|
233
431
|
/** `<style>` elements appended here; the constructed ones are `adoptedStyleSheets`. */
|
|
234
|
-
get styleSheets():
|
|
235
|
-
cssText: any;
|
|
236
|
-
})[];
|
|
237
|
-
set textContent(value: string);
|
|
432
|
+
get styleSheets(): StyleSheetShim[];
|
|
238
433
|
/** A shadow root's text is its content's text, and setting it replaces the content. */
|
|
239
434
|
get textContent(): string;
|
|
435
|
+
set textContent(value: unknown);
|
|
240
436
|
/**
|
|
241
437
|
* Constructed sheets land here; serialized alongside string styles.
|
|
242
438
|
*
|
|
@@ -245,9 +441,8 @@ export class ShadowRootShim extends ContainerShim {
|
|
|
245
441
|
* `root.adoptedStyleSheets = sheet` — the single missing `[…]`, and the most likely way to get
|
|
246
442
|
* this wrong — was accepted here and threw in the browser, after the server had already rendered.
|
|
247
443
|
*/
|
|
248
|
-
set adoptedStyleSheets(sheets:
|
|
249
|
-
get adoptedStyleSheets():
|
|
250
|
-
_adopted: any;
|
|
444
|
+
set adoptedStyleSheets(sheets: unknown);
|
|
445
|
+
get adoptedStyleSheets(): StyleSheetShim[];
|
|
251
446
|
/**
|
|
252
447
|
* The `<style>` tags, kept separate from the content.
|
|
253
448
|
*
|
|
@@ -258,39 +453,46 @@ export class ShadowRootShim extends ContainerShim {
|
|
|
258
453
|
*/
|
|
259
454
|
styleTags(): string;
|
|
260
455
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
456
|
+
/**
|
|
457
|
+
* `Node`'s numeric constants, and the measurements a box that was never laid out reports.
|
|
458
|
+
*
|
|
459
|
+
* Zero is what a browser returns for a detached element, so these are accurate rather than
|
|
460
|
+
* convenient. `currentCSSZoom` is 1 for the same reason.
|
|
461
|
+
*/
|
|
462
|
+
export declare const NODE_CONSTANTS: {
|
|
463
|
+
ELEMENT_NODE: number;
|
|
464
|
+
ATTRIBUTE_NODE: number;
|
|
465
|
+
TEXT_NODE: number;
|
|
466
|
+
CDATA_SECTION_NODE: number;
|
|
467
|
+
ENTITY_REFERENCE_NODE: number;
|
|
468
|
+
ENTITY_NODE: number;
|
|
469
|
+
PROCESSING_INSTRUCTION_NODE: number;
|
|
470
|
+
COMMENT_NODE: number;
|
|
471
|
+
DOCUMENT_NODE: number;
|
|
472
|
+
DOCUMENT_TYPE_NODE: number;
|
|
473
|
+
DOCUMENT_FRAGMENT_NODE: number;
|
|
474
|
+
NOTATION_NODE: number;
|
|
475
|
+
DOCUMENT_POSITION_DISCONNECTED: number;
|
|
476
|
+
DOCUMENT_POSITION_PRECEDING: number;
|
|
477
|
+
DOCUMENT_POSITION_FOLLOWING: number;
|
|
478
|
+
DOCUMENT_POSITION_CONTAINS: number;
|
|
479
|
+
DOCUMENT_POSITION_CONTAINED_BY: number;
|
|
480
|
+
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number;
|
|
481
|
+
};
|
|
482
|
+
export declare class ElementShim extends ContainerShim {
|
|
283
483
|
_ns: string;
|
|
284
484
|
localName: string;
|
|
285
|
-
_attributes: Map<
|
|
485
|
+
_attributes: Map<string, string>;
|
|
286
486
|
_shadowRoot: ShadowRootShim | null;
|
|
287
|
-
/**
|
|
288
|
-
* The bytes this element's own tags were parsed from, when it came from markup rather than
|
|
289
|
-
* `createElement`. Declared here so every element has the same shape — and so a type-checker
|
|
290
|
-
* knows about a field the parser is what assigns.
|
|
291
|
-
*/
|
|
292
487
|
_sourceOpenTag: string | null;
|
|
293
488
|
_sourceCloseTag: string | null;
|
|
489
|
+
/** The component's `observedAttributes`, read at `upgrade`. */
|
|
490
|
+
_observed?: readonly string[];
|
|
491
|
+
_upgraded?: boolean;
|
|
492
|
+
/** Set by `renderComponent` once this instance has rendered. */
|
|
493
|
+
_rendered?: boolean;
|
|
494
|
+
constructor(localName?: string, namespaceURI?: string, made?: typeof MADE);
|
|
495
|
+
get namespaceURI(): string;
|
|
294
496
|
/**
|
|
295
497
|
* An attribute name as this element stores it.
|
|
296
498
|
*
|
|
@@ -301,10 +503,10 @@ export class ElementShim extends ContainerShim {
|
|
|
301
503
|
* attribute handed in as `{ 'User-ID': … }` never matched an `observedAttributes` entry, so
|
|
302
504
|
* `attributeChangedCallback` simply did not fire.
|
|
303
505
|
*/
|
|
304
|
-
_name(name:
|
|
506
|
+
_name(name: unknown): string;
|
|
305
507
|
/**
|
|
306
508
|
* **`mode: 'closed'` means `element.shadowRoot` is `null`** — that is the entire difference between
|
|
307
|
-
* the two modes, and it was not
|
|
509
|
+
* the two modes, and it was not honored: a closed root was handed straight back, so a component
|
|
308
510
|
* guarding on `this.shadowRoot` took the branch the browser will not, and anything holding the
|
|
309
511
|
* element could reach inside a root the platform hides. The root is kept on `_shadowRoot`, because
|
|
310
512
|
* it still has to be serialized — declarative shadow DOM expresses `closed` perfectly well
|
|
@@ -318,16 +520,16 @@ export class ElementShim extends ContainerShim {
|
|
|
318
520
|
* `@verajs/core` already guards against calling this twice *because* the browser throws; the shim
|
|
319
521
|
* accepting it meant the server was the one place that guard was not being checked.
|
|
320
522
|
*/
|
|
321
|
-
attachShadow(init?:
|
|
322
|
-
getAttribute(name:
|
|
323
|
-
setAttribute(name:
|
|
324
|
-
hasAttribute(name:
|
|
523
|
+
attachShadow(init?: ShadowInit): ShadowRootShim;
|
|
524
|
+
getAttribute(name: string): string | null;
|
|
525
|
+
setAttribute(name: string, value: unknown): void;
|
|
526
|
+
hasAttribute(name: string): boolean;
|
|
325
527
|
/**
|
|
326
528
|
* `force` decides, and when the attribute is already in the wanted state **nothing happens** —
|
|
327
529
|
* no write, no callback. This used to reset the value to `''` on `toggleAttribute(name, true)`
|
|
328
530
|
* for an attribute that was already there, which silently erased it.
|
|
329
531
|
*/
|
|
330
|
-
toggleAttribute(name:
|
|
532
|
+
toggleAttribute(name: string, force?: boolean): boolean;
|
|
331
533
|
/**
|
|
332
534
|
* Upgrade, the way the parser does it: `attributeChangedCallback` fires once per **present**
|
|
333
535
|
* observed attribute, before `connectedCallback`, with a `null` old value.
|
|
@@ -338,8 +540,6 @@ export class ElementShim extends ContainerShim {
|
|
|
338
540
|
* mismatch on every such component, and a flash of the wrong content for anyone without JS.
|
|
339
541
|
*/
|
|
340
542
|
upgrade(): void;
|
|
341
|
-
_observed: string[] | undefined;
|
|
342
|
-
_upgraded: boolean | undefined;
|
|
343
543
|
/**
|
|
344
544
|
* And it keeps firing afterwards, because a browser does: a component that changes its own
|
|
345
545
|
* attribute during a render sees the callback on the client and must see it here.
|
|
@@ -348,7 +548,7 @@ export class ElementShim extends ContainerShim {
|
|
|
348
548
|
* an element mid-upgrade has no observers yet, and one that observes nothing never reaches the
|
|
349
549
|
* `includes`.
|
|
350
550
|
*/
|
|
351
|
-
_attributeChanged(name:
|
|
551
|
+
_attributeChanged(name: string, previous: string | null): void;
|
|
352
552
|
/** Enough of a `NamedNodeMap` to iterate, which is what component code does with it. */
|
|
353
553
|
/**
|
|
354
554
|
* An array rather than a live `NamedNodeMap` — already a recorded difference, since there is
|
|
@@ -356,16 +556,25 @@ export class ElementShim extends ContainerShim {
|
|
|
356
556
|
* `attributes.getNamedItem('x')` is how a good deal of existing code reads an attribute, and it
|
|
357
557
|
* was simply missing, so that code got a `TypeError` on the server and worked in a browser.
|
|
358
558
|
*/
|
|
359
|
-
get attributes():
|
|
360
|
-
getAttributeNames():
|
|
559
|
+
get attributes(): NamedNodeMapShim;
|
|
560
|
+
getAttributeNames(): string[];
|
|
361
561
|
/**
|
|
362
562
|
* `this.dataset.x = 'y'` and `this.style.color = 'red'` both change the markup, so both write
|
|
363
563
|
* through to the attribute they are a view of. A plain object would accept the assignment and
|
|
364
564
|
* lose it.
|
|
365
565
|
*/
|
|
366
|
-
get dataset():
|
|
367
|
-
get style():
|
|
368
|
-
|
|
566
|
+
get dataset(): ReturnType<typeof datasetView>;
|
|
567
|
+
get style(): ReturnType<typeof styleView>;
|
|
568
|
+
/**
|
|
569
|
+
* The platform's `style` is `[SameObject, PutForwards=cssText]` — `el.style = 'color: red'`
|
|
570
|
+
* assigns THROUGH to `cssText` in every engine (and in jsdom, the regression net). The shim
|
|
571
|
+
* declared only the getter, so the ordinary spelling threw `Cannot set property` server-side:
|
|
572
|
+
* a component-prop delivery of `.style` was refused as read-only while the client accepted and
|
|
573
|
+
* reflected it — the exact server/client divergence the differential rule exists to catch.
|
|
574
|
+
* `[LegacyNullToEmptyString]` rides the same IDL attribute, so `null` means `''`.
|
|
575
|
+
*/
|
|
576
|
+
set style(value: unknown);
|
|
577
|
+
removeAttribute(name: string): void;
|
|
369
578
|
/**
|
|
370
579
|
* The rest of the surface an ordinary custom element reaches for.
|
|
371
580
|
*
|
|
@@ -378,57 +587,25 @@ export class ElementShim extends ContainerShim {
|
|
|
378
587
|
* They answer the way a detached, childless element would, because that is what this is.
|
|
379
588
|
*/
|
|
380
589
|
get tagName(): string;
|
|
381
|
-
get nodeType():
|
|
590
|
+
get nodeType(): 1;
|
|
382
591
|
get nodeName(): string;
|
|
383
592
|
/** Walks the real parent chain, which exists now that children are nodes. */
|
|
384
|
-
closest(selector:
|
|
385
|
-
matches(selector:
|
|
593
|
+
closest(selector: string): ElementShim | null;
|
|
594
|
+
matches(selector: string): boolean;
|
|
386
595
|
/**
|
|
387
596
|
* **A no-op until nodes were retained** — an appended child had been flattened into its parent's
|
|
388
597
|
* markup, so there was no parent to ask and nothing to take out. It silently left the element on
|
|
389
598
|
* the page.
|
|
390
599
|
*/
|
|
391
600
|
remove(): void;
|
|
392
|
-
/** `[PutForwards=value]`, for the same reason as `part`. */
|
|
393
|
-
set classList(value: {
|
|
394
|
-
add: (...names: any[]) => void;
|
|
395
|
-
remove: (...names: any[]) => void;
|
|
396
|
-
toggle: (name: any, force: any) => any;
|
|
397
|
-
replace: (oldToken: any, newToken: any) => boolean;
|
|
398
|
-
contains: (name: any) => any;
|
|
399
|
-
supports: () => never;
|
|
400
|
-
item: (index: any) => any;
|
|
401
|
-
forEach: (callback: any, thisArg: any) => any;
|
|
402
|
-
keys: () => any;
|
|
403
|
-
values: () => any;
|
|
404
|
-
entries: () => any;
|
|
405
|
-
toString: () => any;
|
|
406
|
-
value: any;
|
|
407
|
-
readonly length: any;
|
|
408
|
-
[Symbol.iterator]: () => any;
|
|
409
|
-
});
|
|
410
601
|
/**
|
|
411
602
|
* Backed by the `class` attribute, so a class added during `connectedCallback` reaches the
|
|
412
603
|
* markup — which it now can, because the opening tag is written from these attributes rather
|
|
413
604
|
* than copied from the source text.
|
|
414
605
|
*/
|
|
415
|
-
get classList():
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
toggle: (name: any, force: any) => any;
|
|
419
|
-
replace: (oldToken: any, newToken: any) => boolean;
|
|
420
|
-
contains: (name: any) => any;
|
|
421
|
-
supports: () => never;
|
|
422
|
-
item: (index: any) => any;
|
|
423
|
-
forEach: (callback: any, thisArg: any) => any;
|
|
424
|
-
keys: () => any;
|
|
425
|
-
values: () => any;
|
|
426
|
-
entries: () => any;
|
|
427
|
-
toString: () => any;
|
|
428
|
-
value: any;
|
|
429
|
-
readonly length: any;
|
|
430
|
-
[Symbol.iterator]: () => any;
|
|
431
|
-
};
|
|
606
|
+
get classList(): ReturnType<typeof tokenListView>;
|
|
607
|
+
/** `[PutForwards=value]`, for the same reason as `part`. */
|
|
608
|
+
set classList(value: unknown);
|
|
432
609
|
/**
|
|
433
610
|
* What a **detached, childless** element answers.
|
|
434
611
|
*
|
|
@@ -460,30 +637,24 @@ export class ElementShim extends ContainerShim {
|
|
|
460
637
|
* "already recorded" while the README said nothing about it — the difference is written down now,
|
|
461
638
|
* along with the `item()`/`namedItem()` half of it that was a side effect rather than a decision.)
|
|
462
639
|
*/
|
|
463
|
-
getElementsByTagName(name:
|
|
464
|
-
getElementsByTagNameNS(namespace:
|
|
465
|
-
getElementsByClassName(names:
|
|
640
|
+
getElementsByTagName(name: string): ElementShim[];
|
|
641
|
+
getElementsByTagNameNS(namespace: string | null, name: string): ElementShim[];
|
|
642
|
+
getElementsByClassName(names: string): ElementShim[];
|
|
466
643
|
/**
|
|
467
644
|
* Namespaces collapse to the plain attribute methods. This DOM serializes HTML, where an
|
|
468
645
|
* `xml:lang` or `xlink:href` is one attribute with a colon in its name — which is how the
|
|
469
646
|
* serializer already treats it, and how the markup reads it back.
|
|
470
647
|
*/
|
|
471
|
-
getAttributeNS(_namespace:
|
|
472
|
-
setAttributeNS(_namespace:
|
|
473
|
-
hasAttributeNS(_namespace:
|
|
474
|
-
removeAttributeNS(_namespace:
|
|
648
|
+
getAttributeNS(_namespace: string | null, name: string): string | null;
|
|
649
|
+
setAttributeNS(_namespace: string | null, name: string, value: unknown): void;
|
|
650
|
+
hasAttributeNS(_namespace: string | null, name: string): boolean;
|
|
651
|
+
removeAttributeNS(_namespace: string | null, name: string): void;
|
|
475
652
|
hasAttributes(): boolean;
|
|
476
|
-
getAttributeNode(name:
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
name: any;
|
|
482
|
-
value: any;
|
|
483
|
-
} | null;
|
|
484
|
-
setAttributeNode(node: any): null;
|
|
485
|
-
setAttributeNodeNS(node: any): null;
|
|
486
|
-
removeAttributeNode(node: any): any;
|
|
653
|
+
getAttributeNode(name: string): AttributeNodeShim | null;
|
|
654
|
+
getAttributeNodeNS(_namespace: string | null, name: string): AttributeNodeShim | null;
|
|
655
|
+
setAttributeNode(node: AttributeNodeShim): null;
|
|
656
|
+
setAttributeNodeNS(node: AttributeNodeShim): null;
|
|
657
|
+
removeAttributeNode<T extends AttributeNodeShim>(node: T): T;
|
|
487
658
|
/** Aliases the engines still carry. */
|
|
488
659
|
webkitMatchesSelector(): boolean;
|
|
489
660
|
mozMatchesSelector(): boolean;
|
|
@@ -516,9 +687,11 @@ export class ElementShim extends ContainerShim {
|
|
|
516
687
|
* does not would render one page and hydrate into another. `insertAdjacentText` escapes, which is
|
|
517
688
|
* the difference between the two methods and the one to reach for with anything from a request.
|
|
518
689
|
*/
|
|
519
|
-
insertAdjacentHTML(position:
|
|
520
|
-
insertAdjacentText(position:
|
|
521
|
-
insertAdjacentElement(position:
|
|
690
|
+
insertAdjacentHTML(position: string, markup: unknown): void;
|
|
691
|
+
insertAdjacentText(position: string, text: unknown): void;
|
|
692
|
+
insertAdjacentElement<T extends ElementShim>(position: string, element: T): T;
|
|
693
|
+
/** The element's own markup, which the serializer builds anyway. */
|
|
694
|
+
get outerHTML(): string;
|
|
522
695
|
/**
|
|
523
696
|
* **Replaces this element in its parent with the given markup.** Assigning it used to be a
|
|
524
697
|
* `TypeError` — there was no setter — so `element.outerHTML = '<p>x</p>'`, an ordinary way to swap
|
|
@@ -528,9 +701,8 @@ export class ElementShim extends ContainerShim {
|
|
|
528
701
|
* do — measured, because the obvious guess was a `NoModificationAllowedError` and that is wrong:
|
|
529
702
|
* the spec raises it only when the parent is a *Document*, not when there is no parent at all.
|
|
530
703
|
*/
|
|
531
|
-
set outerHTML(markup:
|
|
532
|
-
|
|
533
|
-
get outerHTML(): any;
|
|
704
|
+
set outerHTML(markup: unknown);
|
|
705
|
+
get innerText(): string;
|
|
534
706
|
/**
|
|
535
707
|
* **A line break becomes a `<br>`, which is the whole difference from `textContent`.** Every
|
|
536
708
|
* engine splits the assigned string on `\r\n`, `\r` and `\n` and joins the escaped pieces with
|
|
@@ -542,8 +714,9 @@ export class ElementShim extends ContainerShim {
|
|
|
542
714
|
* Measured on Chromium, Firefox and WebKit, attached and detached, in
|
|
543
715
|
* `tests/browser/inner-text.test.js`.
|
|
544
716
|
*/
|
|
545
|
-
set innerText(value:
|
|
546
|
-
|
|
717
|
+
set innerText(value: unknown);
|
|
718
|
+
/** `part` is a token list over the `part` attribute, exactly as `classList` is over `class`. */
|
|
719
|
+
get part(): ReturnType<typeof tokenListView>;
|
|
547
720
|
/**
|
|
548
721
|
* **Assignable, because the IDL says `[PutForwards=value]`.** Both `part` and `classList` are
|
|
549
722
|
* declared that way, so `element.part = 'a b'` is a legal operation in every engine and writes
|
|
@@ -551,41 +724,7 @@ export class ElementShim extends ContainerShim {
|
|
|
551
724
|
* refuses what the browser performs, which is the same failure as being too permissive with the
|
|
552
725
|
* direction reversed.
|
|
553
726
|
*/
|
|
554
|
-
set part(value:
|
|
555
|
-
add: (...names: any[]) => void;
|
|
556
|
-
remove: (...names: any[]) => void;
|
|
557
|
-
toggle: (name: any, force: any) => any;
|
|
558
|
-
replace: (oldToken: any, newToken: any) => boolean;
|
|
559
|
-
contains: (name: any) => any;
|
|
560
|
-
supports: () => never;
|
|
561
|
-
item: (index: any) => any;
|
|
562
|
-
forEach: (callback: any, thisArg: any) => any;
|
|
563
|
-
keys: () => any;
|
|
564
|
-
values: () => any;
|
|
565
|
-
entries: () => any;
|
|
566
|
-
toString: () => any;
|
|
567
|
-
value: any;
|
|
568
|
-
readonly length: any;
|
|
569
|
-
[Symbol.iterator]: () => any;
|
|
570
|
-
});
|
|
571
|
-
/** `part` is a token list over the `part` attribute, exactly as `classList` is over `class`. */
|
|
572
|
-
get part(): {
|
|
573
|
-
add: (...names: any[]) => void;
|
|
574
|
-
remove: (...names: any[]) => void;
|
|
575
|
-
toggle: (name: any, force: any) => any;
|
|
576
|
-
replace: (oldToken: any, newToken: any) => boolean;
|
|
577
|
-
contains: (name: any) => any;
|
|
578
|
-
supports: () => never;
|
|
579
|
-
item: (index: any) => any;
|
|
580
|
-
forEach: (callback: any, thisArg: any) => any;
|
|
581
|
-
keys: () => any;
|
|
582
|
-
values: () => any;
|
|
583
|
-
entries: () => any;
|
|
584
|
-
toString: () => any;
|
|
585
|
-
value: any;
|
|
586
|
-
readonly length: any;
|
|
587
|
-
[Symbol.iterator]: () => any;
|
|
588
|
-
};
|
|
727
|
+
set part(value: unknown);
|
|
589
728
|
/**
|
|
590
729
|
* Form-associated custom elements.
|
|
591
730
|
*
|
|
@@ -595,7 +734,7 @@ export class ElementShim extends ContainerShim {
|
|
|
595
734
|
* internal state), so this is inert by design rather than by omission: the component runs, and
|
|
596
735
|
* the client's real internals take over on hydration.
|
|
597
736
|
*/
|
|
598
|
-
attachInternals():
|
|
737
|
+
attachInternals(): InternalsShim;
|
|
599
738
|
/**
|
|
600
739
|
* The element's own opening tag, written from the attributes it holds **now**.
|
|
601
740
|
*
|
|
@@ -609,7 +748,7 @@ export class ElementShim extends ContainerShim {
|
|
|
609
748
|
* markup string would alias it; entries are an array now, so a deep clone copies them. The source
|
|
610
749
|
* text rides along, so a cloned subtree still reproduces the markup it was parsed from.
|
|
611
750
|
*/
|
|
612
|
-
cloneNode(deep?: boolean):
|
|
751
|
+
cloneNode(deep?: boolean): ElementShim;
|
|
613
752
|
/** This element's own markup, end tag included — the call every node kind answers. */
|
|
614
753
|
/**
|
|
615
754
|
* A `<slot>` shows the host's children that name it; see `assignedTo`.
|
|
@@ -620,10 +759,23 @@ export class ElementShim extends ContainerShim {
|
|
|
620
759
|
* answered yes for a `<div>`. Being present where the platform has nothing is the same kind of
|
|
621
760
|
* divergence as answering wrongly, and it is the one a feature check walks straight into.
|
|
622
761
|
*/
|
|
623
|
-
get assignedNodes(): ((options
|
|
624
|
-
|
|
625
|
-
|
|
762
|
+
get assignedNodes(): ((options?: {
|
|
763
|
+
flatten?: boolean;
|
|
764
|
+
}) => ChildShim[]) | undefined;
|
|
765
|
+
get assignedElements(): ((options?: {
|
|
766
|
+
flatten?: boolean;
|
|
767
|
+
}) => ElementShim[]) | undefined;
|
|
768
|
+
markup(): string;
|
|
626
769
|
openTag(): string;
|
|
770
|
+
/**
|
|
771
|
+
* Tags stripped and the escaping undone, so what goes in comes back out.
|
|
772
|
+
*
|
|
773
|
+
* Reading back what `textContent` had just written returned `<b>` for `<b>` — the setter
|
|
774
|
+
* escapes and the getter did not decode, so the round trip a component may reasonably rely on was
|
|
775
|
+
* broken. Only the numeric references the setter emits need undoing; anything else in there came
|
|
776
|
+
* from author markup and is text as written.
|
|
777
|
+
*/
|
|
778
|
+
get textContent(): string;
|
|
627
779
|
/**
|
|
628
780
|
* Escaped for an ordinary element, stored as-is for a raw-text one.
|
|
629
781
|
*
|
|
@@ -640,18 +792,9 @@ export class ElementShim extends ContainerShim {
|
|
|
640
792
|
* which meant `this.textContent = maybeMissing` put the word on the page server-side and nothing
|
|
641
793
|
* client-side: a hydration mismatch produced by ordinary defensive code.
|
|
642
794
|
*/
|
|
643
|
-
set textContent(value:
|
|
644
|
-
/**
|
|
645
|
-
* Tags stripped and the escaping undone, so what goes in comes back out.
|
|
646
|
-
*
|
|
647
|
-
* Reading back what `textContent` had just written returned `<b>` for `<b>` — the setter
|
|
648
|
-
* escapes and the getter did not decode, so the round trip a component may reasonably rely on was
|
|
649
|
-
* broken. Only the numeric references the setter emits need undoing; anything else in there came
|
|
650
|
-
* from author markup and is text as written.
|
|
651
|
-
*/
|
|
652
|
-
get textContent(): string;
|
|
795
|
+
set textContent(value: unknown);
|
|
653
796
|
}
|
|
654
|
-
export
|
|
797
|
+
export declare const createElement: (localName: unknown, namespaceURI?: string) => ElementShim;
|
|
655
798
|
/**
|
|
656
799
|
* Instances handed to `appendChild` before they have rendered, so the scan renders **them** rather
|
|
657
800
|
* than a fresh copy built from their markup.
|
|
@@ -662,7 +805,7 @@ export function createElement(localName: any, namespaceURI?: string): any;
|
|
|
662
805
|
* lost, because an attribute cannot carry it and a fresh instance never saw it. The marker attribute
|
|
663
806
|
* is the handle, and `renderComponent` removes it as it renders.
|
|
664
807
|
*/
|
|
665
|
-
export const pendingInstances: Map<
|
|
808
|
+
export declare const pendingInstances: Map<string, ElementShim>;
|
|
666
809
|
/**
|
|
667
810
|
* The marker's **name** carries a per-process random token, because the markup it is written into is
|
|
668
811
|
* not all ours.
|
|
@@ -678,61 +821,15 @@ export const pendingInstances: Map<any, any>;
|
|
|
678
821
|
* Import-time rather than per-render: an attacker cannot read either, and the output never contains
|
|
679
822
|
* the marker, so nothing observable depends on it.
|
|
680
823
|
*/
|
|
681
|
-
export const INSTANCE_ATTRIBUTE: string;
|
|
824
|
+
export declare const INSTANCE_ATTRIBUTE: string;
|
|
682
825
|
/**
|
|
683
|
-
*
|
|
826
|
+
* Marks `node` as a prepared instance and returns its id, so the nested-component scan renders THIS
|
|
827
|
+
* instance rather than a fresh copy built from its markup. Two callers, one discipline:
|
|
828
|
+
* `appendChild` below, for an element a component built itself, and the template serializer, for a
|
|
829
|
+
* component tag whose property bindings it is delivering — both stamp the node (so `prepareInstance`
|
|
830
|
+
* can unregister it by the attribute) and both rely on the unguessable name above.
|
|
684
831
|
*
|
|
685
|
-
*
|
|
686
|
-
* no identity, no parent and no `nodeType`, and appending one inlined its markup and lost the node.
|
|
687
|
-
* `childNodes` therefore reported `1` for `text <b>bold</b> tail`, where every browser says `3`.
|
|
688
|
-
*
|
|
689
|
-
* Like an element, a parsed one keeps **the exact bytes it came from** so re-serialising reproduces
|
|
690
|
-
* the input — `&` stays `&` rather than becoming this package's `&` — and falls back to
|
|
691
|
-
* escaping its data the moment somebody writes to it.
|
|
832
|
+
* @returns the instance id, for the caller that writes markup itself
|
|
692
833
|
*/
|
|
693
|
-
declare
|
|
694
|
-
constructor(data: any);
|
|
695
|
-
_data: string;
|
|
696
|
-
_source: string | null;
|
|
697
|
-
_parent: any;
|
|
698
|
-
isConnected: boolean;
|
|
699
|
-
/**
|
|
700
|
-
* Registered here rather than on the platform's `EventTarget`; see `events.js`.
|
|
701
|
-
* @override
|
|
702
|
-
*/
|
|
703
|
-
override addEventListener(type: any, callback: any, options: any): void;
|
|
704
|
-
/** @override */
|
|
705
|
-
override removeEventListener(type: any, callback: any, options: any): void;
|
|
706
|
-
/** @override */
|
|
707
|
-
override dispatchEvent(event: any): boolean;
|
|
708
|
-
set data(value: string);
|
|
709
|
-
get data(): string;
|
|
710
|
-
set nodeValue(value: string);
|
|
711
|
-
get nodeValue(): string;
|
|
712
|
-
set textContent(value: string);
|
|
713
|
-
get textContent(): string;
|
|
714
|
-
get length(): number;
|
|
715
|
-
get parentNode(): any;
|
|
716
|
-
get parentElement(): any;
|
|
717
|
-
get childNodes(): never[];
|
|
718
|
-
get firstChild(): null;
|
|
719
|
-
get lastChild(): null;
|
|
720
|
-
hasChildNodes(): boolean;
|
|
721
|
-
get ownerDocument(): Document;
|
|
722
|
-
get nextSibling(): any;
|
|
723
|
-
get previousSibling(): any;
|
|
724
|
-
/** @param {number} step @param {(container: any) => Array<any>} view */
|
|
725
|
-
_siblingAt(step: number, view?: (container: any) => Array<any>): any;
|
|
726
|
-
remove(): void;
|
|
727
|
-
before(...nodes: any[]): void;
|
|
728
|
-
after(...nodes: any[]): void;
|
|
729
|
-
replaceWith(...nodes: any[]): void;
|
|
730
|
-
isSameNode(node: any): boolean;
|
|
731
|
-
isEqualNode(node: any): boolean;
|
|
732
|
-
contains(node: any): boolean;
|
|
733
|
-
getRootNode(): any;
|
|
734
|
-
appendData(value: any): void;
|
|
735
|
-
substringData(offset: any, count: any): string;
|
|
736
|
-
}
|
|
737
|
-
import { StyleSheetShim } from './stylesheets.js';
|
|
834
|
+
export declare const markPending: (node: ElementShim) => string;
|
|
738
835
|
export {};
|