defuddle-cli 0.1.4 → 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/dist/dom/document.d.ts +3 -0
- package/dist/dom/document.js +49 -0
- package/dist/dom/elements.d.ts +2 -0
- package/dist/dom/elements.js +478 -0
- package/dist/dom/interfaces/elements/base.d.ts +14 -0
- package/dist/dom/interfaces/elements/base.js +46 -0
- package/dist/dom/interfaces/elements/form.d.ts +2 -0
- package/dist/dom/interfaces/elements/form.js +123 -0
- package/dist/dom/interfaces/elements/index.d.ts +2 -0
- package/dist/dom/interfaces/elements/index.js +22 -0
- package/dist/dom/interfaces/elements/interactive.d.ts +2 -0
- package/dist/dom/interfaces/elements/interactive.js +83 -0
- package/dist/dom/interfaces/elements/media.d.ts +2 -0
- package/dist/dom/interfaces/elements/media.js +43 -0
- package/dist/dom/interfaces/elements/table.d.ts +2 -0
- package/dist/dom/interfaces/elements/table.js +155 -0
- package/dist/dom/interfaces/elements/text.d.ts +2 -0
- package/dist/dom/interfaces/elements/text.js +57 -0
- package/dist/dom/interfaces/elements.d.ts +2 -0
- package/dist/dom/interfaces/elements.js +478 -0
- package/dist/dom/interfaces/range.d.ts +1 -1
- package/dist/dom/range.d.ts +2 -0
- package/dist/dom/range.js +87 -0
- package/dist/dom/setup/document.d.ts +3 -0
- package/dist/dom/setup/document.js +49 -0
- package/dist/dom/setup.d.ts +12 -9
- package/dist/dom/setup.js +148 -533
- package/dist/dom/types/setup.d.ts +10 -0
- package/dist/dom/types/setup.js +1 -0
- package/dist/index.js +10 -684
- package/package.json +3 -5
- package/src/index.ts +10 -772
- package/src/dom/interfaces/document.ts +0 -53
- package/src/dom/interfaces/range.ts +0 -120
- package/src/dom/interfaces/setup.ts +0 -196
- package/src/markdown.ts +0 -592
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const setupDocumentMethods = (window) => {
|
|
2
|
+
if (!window.Document.prototype.getSelection) {
|
|
3
|
+
window.Document.prototype.getSelection = function () {
|
|
4
|
+
const selection = {
|
|
5
|
+
anchorNode: null,
|
|
6
|
+
anchorOffset: 0,
|
|
7
|
+
direction: 'forward',
|
|
8
|
+
focusNode: null,
|
|
9
|
+
focusOffset: 0,
|
|
10
|
+
isCollapsed: true,
|
|
11
|
+
rangeCount: 0,
|
|
12
|
+
type: 'None',
|
|
13
|
+
getRangeAt: function () { return new window.Range(); },
|
|
14
|
+
removeAllRanges: function () { },
|
|
15
|
+
addRange: function () { },
|
|
16
|
+
collapse: function () { },
|
|
17
|
+
collapseToEnd: function () { },
|
|
18
|
+
collapseToStart: function () { },
|
|
19
|
+
deleteFromDocument: function () { },
|
|
20
|
+
empty: function () { },
|
|
21
|
+
extend: function () { },
|
|
22
|
+
modify: function () { },
|
|
23
|
+
selectAllChildren: function () { },
|
|
24
|
+
setBaseAndExtent: function () { },
|
|
25
|
+
setPosition: function () { },
|
|
26
|
+
toString: function () { return ''; },
|
|
27
|
+
containsNode: function (node, allowPartialContainment = false) {
|
|
28
|
+
return false;
|
|
29
|
+
},
|
|
30
|
+
removeRange: function (range) { }
|
|
31
|
+
};
|
|
32
|
+
return selection;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const setupWindowMethods = (window) => {
|
|
37
|
+
if (!window.Window.prototype.getComputedStyle) {
|
|
38
|
+
window.Window.prototype.getComputedStyle = function (elt, pseudoElt) {
|
|
39
|
+
const style = {
|
|
40
|
+
accentColor: '',
|
|
41
|
+
alignContent: '',
|
|
42
|
+
alignItems: '',
|
|
43
|
+
alignSelf: '',
|
|
44
|
+
getPropertyValue: function (prop) { return ''; }
|
|
45
|
+
};
|
|
46
|
+
return style;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
export function setupElements(window) {
|
|
2
|
+
// Define HTMLElement globally
|
|
3
|
+
globalThis.HTMLElement = window.HTMLElement;
|
|
4
|
+
// Add window to global scope
|
|
5
|
+
globalThis.window = window;
|
|
6
|
+
// Add document to global scope
|
|
7
|
+
globalThis.document = window.document;
|
|
8
|
+
// Add required DOM interfaces to global scope
|
|
9
|
+
globalThis.Element = window.Element;
|
|
10
|
+
globalThis.Node = window.Node;
|
|
11
|
+
globalThis.NodeFilter = window.NodeFilter;
|
|
12
|
+
globalThis.Range = window.Range;
|
|
13
|
+
globalThis.DOMParser = window.DOMParser;
|
|
14
|
+
globalThis.XMLSerializer = window.XMLSerializer;
|
|
15
|
+
// Handle navigator property
|
|
16
|
+
if (!globalThis.navigator || Object.getOwnPropertyDescriptor(globalThis, 'navigator')?.configurable) {
|
|
17
|
+
Object.defineProperty(globalThis, 'navigator', {
|
|
18
|
+
value: window.navigator,
|
|
19
|
+
writable: false,
|
|
20
|
+
configurable: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// Define DOMSettableTokenList
|
|
24
|
+
globalThis.DOMSettableTokenList = class {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.length = 0;
|
|
27
|
+
this.value = '';
|
|
28
|
+
}
|
|
29
|
+
add(token) { }
|
|
30
|
+
contains(token) { return false; }
|
|
31
|
+
item(index) { return null; }
|
|
32
|
+
remove(token) { }
|
|
33
|
+
replace(oldToken, newToken) { return false; }
|
|
34
|
+
supports(token) { return false; }
|
|
35
|
+
toggle(token, force) { return false; }
|
|
36
|
+
[Symbol.iterator]() {
|
|
37
|
+
return function* () { yield ''; return undefined; }();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
// Define SVGElement globally
|
|
41
|
+
globalThis.SVGElement = class {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.id = '';
|
|
44
|
+
this.className = '';
|
|
45
|
+
this.style = {
|
|
46
|
+
cssText: '',
|
|
47
|
+
length: 0,
|
|
48
|
+
parentRule: null,
|
|
49
|
+
getPropertyPriority: () => '',
|
|
50
|
+
getPropertyValue: () => '',
|
|
51
|
+
item: () => '',
|
|
52
|
+
removeProperty: () => '',
|
|
53
|
+
setProperty: () => '',
|
|
54
|
+
[Symbol.iterator]: function* () { yield ''; return undefined; }
|
|
55
|
+
};
|
|
56
|
+
this.ownerSVGElement = null;
|
|
57
|
+
this.viewportElement = null;
|
|
58
|
+
this.tagName = '';
|
|
59
|
+
this.namespaceURI = null;
|
|
60
|
+
this.prefix = null;
|
|
61
|
+
this.localName = '';
|
|
62
|
+
this.baseURI = '';
|
|
63
|
+
this.textContent = '';
|
|
64
|
+
this.innerHTML = '';
|
|
65
|
+
this.outerHTML = '';
|
|
66
|
+
this.hidden = false;
|
|
67
|
+
this.slot = '';
|
|
68
|
+
this.attributes = {
|
|
69
|
+
length: 0,
|
|
70
|
+
getNamedItem: () => null,
|
|
71
|
+
getNamedItemNS: () => null,
|
|
72
|
+
item: () => null,
|
|
73
|
+
removeNamedItem: () => null,
|
|
74
|
+
removeNamedItemNS: () => null,
|
|
75
|
+
setNamedItem: () => null,
|
|
76
|
+
setNamedItemNS: () => null,
|
|
77
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
78
|
+
};
|
|
79
|
+
this.childNodes = {
|
|
80
|
+
length: 0,
|
|
81
|
+
item: () => null,
|
|
82
|
+
forEach: () => { },
|
|
83
|
+
entries: function* () { yield [0, null]; return undefined; },
|
|
84
|
+
keys: function* () { yield 0; return undefined; },
|
|
85
|
+
values: function* () { yield null; return undefined; },
|
|
86
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
87
|
+
};
|
|
88
|
+
this.firstChild = null;
|
|
89
|
+
this.lastChild = null;
|
|
90
|
+
this.nextSibling = null;
|
|
91
|
+
this.previousSibling = null;
|
|
92
|
+
this.parentNode = null;
|
|
93
|
+
this.parentElement = null;
|
|
94
|
+
this.childElementCount = 0;
|
|
95
|
+
this.firstElementChild = null;
|
|
96
|
+
this.lastElementChild = null;
|
|
97
|
+
this.nextElementSibling = null;
|
|
98
|
+
this.previousElementSibling = null;
|
|
99
|
+
this.children = {
|
|
100
|
+
length: 0,
|
|
101
|
+
item: () => null,
|
|
102
|
+
namedItem: () => null,
|
|
103
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
104
|
+
};
|
|
105
|
+
// Initialize any required properties
|
|
106
|
+
}
|
|
107
|
+
getAttribute(name) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
getAttributeNS(namespaceURI, localName) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
setAttribute(name, value) { }
|
|
114
|
+
setAttributeNS(namespaceURI, qualifiedName, value) { }
|
|
115
|
+
removeAttributeNS(namespaceURI, localName) { }
|
|
116
|
+
hasAttribute(name) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
hasAttributeNS(namespaceURI, localName) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
getBoundingClientRect() {
|
|
123
|
+
return {
|
|
124
|
+
top: 0,
|
|
125
|
+
left: 0,
|
|
126
|
+
bottom: 0,
|
|
127
|
+
right: 0,
|
|
128
|
+
width: 0,
|
|
129
|
+
height: 0,
|
|
130
|
+
x: 0,
|
|
131
|
+
y: 0,
|
|
132
|
+
toJSON: function () { return this; }
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
getClientRects() {
|
|
136
|
+
return {
|
|
137
|
+
length: 0,
|
|
138
|
+
item: function () { return null; },
|
|
139
|
+
[Symbol.iterator]: function* () { }
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
getElementsByClassName(classNames) {
|
|
143
|
+
return {
|
|
144
|
+
length: 0,
|
|
145
|
+
item: () => null,
|
|
146
|
+
namedItem: () => null,
|
|
147
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
getElementsByTagName(qualifiedName) {
|
|
151
|
+
return {
|
|
152
|
+
length: 0,
|
|
153
|
+
item: () => null,
|
|
154
|
+
namedItem: () => null,
|
|
155
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
getElementsByTagNameNS(namespaceURI, localName) {
|
|
159
|
+
return {
|
|
160
|
+
length: 0,
|
|
161
|
+
item: () => null,
|
|
162
|
+
namedItem: () => null,
|
|
163
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
querySelector(selectors) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
querySelectorAll(selectors) {
|
|
170
|
+
return {
|
|
171
|
+
length: 0,
|
|
172
|
+
item: () => null,
|
|
173
|
+
forEach: () => { },
|
|
174
|
+
entries: function* () { yield [0, null]; return undefined; },
|
|
175
|
+
keys: function* () { yield 0; return undefined; },
|
|
176
|
+
values: function* () { yield null; return undefined; },
|
|
177
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
matches(selectors) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
closest(selectors) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
contains(other) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
append(...nodes) { }
|
|
190
|
+
prepend(...nodes) { }
|
|
191
|
+
after(...nodes) { }
|
|
192
|
+
before(...nodes) { }
|
|
193
|
+
replaceWith(...nodes) { }
|
|
194
|
+
remove() { }
|
|
195
|
+
insertAdjacentElement(where, element) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
insertAdjacentText(where, data) { }
|
|
199
|
+
insertAdjacentHTML(position, text) { }
|
|
200
|
+
replaceChildren(...nodes) { }
|
|
201
|
+
};
|
|
202
|
+
// Define HTMLImageElement globally
|
|
203
|
+
globalThis.HTMLImageElement = class {
|
|
204
|
+
constructor() {
|
|
205
|
+
this.alt = '';
|
|
206
|
+
this.src = '';
|
|
207
|
+
this.srcset = '';
|
|
208
|
+
this.sizes = '';
|
|
209
|
+
this.crossOrigin = null;
|
|
210
|
+
this.useMap = '';
|
|
211
|
+
this.isMap = false;
|
|
212
|
+
this.width = 0;
|
|
213
|
+
this.height = 0;
|
|
214
|
+
this.naturalWidth = 0;
|
|
215
|
+
this.naturalHeight = 0;
|
|
216
|
+
this.complete = false;
|
|
217
|
+
this.name = '';
|
|
218
|
+
this.lowsrc = '';
|
|
219
|
+
this.align = '';
|
|
220
|
+
this.hspace = 0;
|
|
221
|
+
this.vspace = 0;
|
|
222
|
+
this.longDesc = '';
|
|
223
|
+
this.border = '';
|
|
224
|
+
this.x = 0;
|
|
225
|
+
this.y = 0;
|
|
226
|
+
this.currentSrc = '';
|
|
227
|
+
this.decoding = 'auto';
|
|
228
|
+
this.fetchPriority = 'auto';
|
|
229
|
+
this.loading = 'eager';
|
|
230
|
+
this.referrerPolicy = '';
|
|
231
|
+
// Initialize any required properties
|
|
232
|
+
}
|
|
233
|
+
decode() {
|
|
234
|
+
return Promise.resolve();
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
// Define HTML element types
|
|
238
|
+
globalThis.HTMLIFrameElement = class extends globalThis.HTMLElement {
|
|
239
|
+
constructor() {
|
|
240
|
+
super();
|
|
241
|
+
this.align = '';
|
|
242
|
+
this.allow = '';
|
|
243
|
+
this.allowFullscreen = false;
|
|
244
|
+
this.contentDocument = null;
|
|
245
|
+
this.contentWindow = null;
|
|
246
|
+
this.frameBorder = '';
|
|
247
|
+
this.height = '';
|
|
248
|
+
this.longDesc = '';
|
|
249
|
+
this.marginHeight = '';
|
|
250
|
+
this.marginWidth = '';
|
|
251
|
+
this.name = '';
|
|
252
|
+
this.referrerPolicy = '';
|
|
253
|
+
this.sandbox = {
|
|
254
|
+
length: 0,
|
|
255
|
+
value: '',
|
|
256
|
+
add: () => { },
|
|
257
|
+
contains: () => false,
|
|
258
|
+
item: () => null,
|
|
259
|
+
remove: () => { },
|
|
260
|
+
replace: () => false,
|
|
261
|
+
supports: () => false,
|
|
262
|
+
toggle: () => false,
|
|
263
|
+
[Symbol.iterator]: function* () { yield ''; return undefined; }
|
|
264
|
+
};
|
|
265
|
+
this.scrolling = '';
|
|
266
|
+
this.src = '';
|
|
267
|
+
this.srcdoc = '';
|
|
268
|
+
this.width = '';
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
globalThis.HTMLOListElement = class extends globalThis.HTMLElement {
|
|
272
|
+
constructor() {
|
|
273
|
+
super();
|
|
274
|
+
this.type = '';
|
|
275
|
+
this.compact = false;
|
|
276
|
+
this.reversed = false;
|
|
277
|
+
this.start = 0;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
globalThis.HTMLUListElement = class extends globalThis.HTMLElement {
|
|
281
|
+
constructor() {
|
|
282
|
+
super();
|
|
283
|
+
this.type = '';
|
|
284
|
+
this.compact = false;
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
globalThis.HTMLTableElement = class extends globalThis.HTMLElement {
|
|
288
|
+
constructor() {
|
|
289
|
+
super();
|
|
290
|
+
this.caption = null;
|
|
291
|
+
this.tHead = null;
|
|
292
|
+
this.tFoot = null;
|
|
293
|
+
this.tBodies = {
|
|
294
|
+
length: 0,
|
|
295
|
+
item: () => null,
|
|
296
|
+
namedItem: () => null,
|
|
297
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
298
|
+
};
|
|
299
|
+
this.rows = {
|
|
300
|
+
length: 0,
|
|
301
|
+
item: () => null,
|
|
302
|
+
namedItem: () => null,
|
|
303
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
304
|
+
};
|
|
305
|
+
this.align = '';
|
|
306
|
+
this.bgColor = '';
|
|
307
|
+
this.border = '';
|
|
308
|
+
this.cellPadding = '';
|
|
309
|
+
this.cellSpacing = '';
|
|
310
|
+
this.frame = '';
|
|
311
|
+
this.rules = '';
|
|
312
|
+
this.summary = '';
|
|
313
|
+
this.width = '';
|
|
314
|
+
}
|
|
315
|
+
createCaption() {
|
|
316
|
+
return new globalThis.HTMLTableCaptionElement();
|
|
317
|
+
}
|
|
318
|
+
deleteCaption() { }
|
|
319
|
+
createTHead() {
|
|
320
|
+
return new globalThis.HTMLTableSectionElement();
|
|
321
|
+
}
|
|
322
|
+
deleteTHead() { }
|
|
323
|
+
createTFoot() {
|
|
324
|
+
return new globalThis.HTMLTableSectionElement();
|
|
325
|
+
}
|
|
326
|
+
deleteTFoot() { }
|
|
327
|
+
createTBody() {
|
|
328
|
+
return new globalThis.HTMLTableSectionElement();
|
|
329
|
+
}
|
|
330
|
+
insertRow(index) {
|
|
331
|
+
return new globalThis.HTMLTableRowElement();
|
|
332
|
+
}
|
|
333
|
+
deleteRow(index) { }
|
|
334
|
+
};
|
|
335
|
+
globalThis.HTMLTableRowElement = class extends globalThis.HTMLElement {
|
|
336
|
+
constructor() {
|
|
337
|
+
super();
|
|
338
|
+
this.rowIndex = 0;
|
|
339
|
+
this.sectionRowIndex = 0;
|
|
340
|
+
this.cells = {
|
|
341
|
+
length: 0,
|
|
342
|
+
item: () => null,
|
|
343
|
+
namedItem: () => null,
|
|
344
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
345
|
+
};
|
|
346
|
+
this.align = '';
|
|
347
|
+
this.bgColor = '';
|
|
348
|
+
this.ch = '';
|
|
349
|
+
this.chOff = '';
|
|
350
|
+
this.vAlign = '';
|
|
351
|
+
}
|
|
352
|
+
insertCell(index) {
|
|
353
|
+
return new globalThis.HTMLTableCellElement();
|
|
354
|
+
}
|
|
355
|
+
deleteCell(index) { }
|
|
356
|
+
};
|
|
357
|
+
globalThis.HTMLTableCellElement = class extends globalThis.HTMLElement {
|
|
358
|
+
constructor() {
|
|
359
|
+
super();
|
|
360
|
+
this.colSpan = 1;
|
|
361
|
+
this.rowSpan = 1;
|
|
362
|
+
this.headers = {
|
|
363
|
+
length: 0,
|
|
364
|
+
value: '',
|
|
365
|
+
add: () => { },
|
|
366
|
+
contains: () => false,
|
|
367
|
+
item: () => null,
|
|
368
|
+
remove: () => { },
|
|
369
|
+
replace: () => false,
|
|
370
|
+
supports: () => false,
|
|
371
|
+
toggle: () => false,
|
|
372
|
+
[Symbol.iterator]: function* () { yield ''; return undefined; }
|
|
373
|
+
};
|
|
374
|
+
this.cellIndex = 0;
|
|
375
|
+
this.scope = '';
|
|
376
|
+
this.abbr = '';
|
|
377
|
+
this.align = '';
|
|
378
|
+
this.axis = '';
|
|
379
|
+
this.bgColor = '';
|
|
380
|
+
this.ch = '';
|
|
381
|
+
this.chOff = '';
|
|
382
|
+
this.height = '';
|
|
383
|
+
this.noWrap = false;
|
|
384
|
+
this.vAlign = '';
|
|
385
|
+
this.width = '';
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
globalThis.HTMLTableSectionElement = class extends globalThis.HTMLElement {
|
|
389
|
+
constructor() {
|
|
390
|
+
super();
|
|
391
|
+
this.rows = {
|
|
392
|
+
length: 0,
|
|
393
|
+
item: () => null,
|
|
394
|
+
namedItem: () => null,
|
|
395
|
+
[Symbol.iterator]: function* () { yield null; return undefined; }
|
|
396
|
+
};
|
|
397
|
+
this.align = '';
|
|
398
|
+
this.ch = '';
|
|
399
|
+
this.chOff = '';
|
|
400
|
+
this.vAlign = '';
|
|
401
|
+
}
|
|
402
|
+
insertRow(index) {
|
|
403
|
+
return new globalThis.HTMLTableRowElement();
|
|
404
|
+
}
|
|
405
|
+
deleteRow(index) { }
|
|
406
|
+
};
|
|
407
|
+
globalThis.HTMLTableCaptionElement = class extends globalThis.HTMLElement {
|
|
408
|
+
constructor() {
|
|
409
|
+
super();
|
|
410
|
+
this.align = '';
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
globalThis.HTMLButtonElement = class extends globalThis.HTMLElement {
|
|
414
|
+
constructor() {
|
|
415
|
+
super();
|
|
416
|
+
this.disabled = false;
|
|
417
|
+
this.form = null;
|
|
418
|
+
this.formAction = '';
|
|
419
|
+
this.formEnctype = '';
|
|
420
|
+
this.formMethod = '';
|
|
421
|
+
this.formNoValidate = false;
|
|
422
|
+
this.formTarget = '';
|
|
423
|
+
this.name = '';
|
|
424
|
+
this.type = 'submit';
|
|
425
|
+
this.value = '';
|
|
426
|
+
this.menu = null;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
// HTMLSpanElement interface
|
|
430
|
+
globalThis.HTMLSpanElement = class extends globalThis.HTMLElement {
|
|
431
|
+
constructor() {
|
|
432
|
+
super();
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
// HTMLDivElement interface
|
|
436
|
+
globalThis.HTMLDivElement = class extends globalThis.HTMLElement {
|
|
437
|
+
constructor() {
|
|
438
|
+
super();
|
|
439
|
+
this.align = '';
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
globalThis.HTMLAnchorElement = class extends globalThis.HTMLElement {
|
|
443
|
+
constructor() {
|
|
444
|
+
super();
|
|
445
|
+
this.href = '';
|
|
446
|
+
this.target = '';
|
|
447
|
+
this.download = '';
|
|
448
|
+
this.ping = '';
|
|
449
|
+
this.rel = '';
|
|
450
|
+
this.relList = {
|
|
451
|
+
length: 0,
|
|
452
|
+
value: '',
|
|
453
|
+
add: () => { },
|
|
454
|
+
contains: () => false,
|
|
455
|
+
item: () => null,
|
|
456
|
+
remove: () => { },
|
|
457
|
+
replace: () => false,
|
|
458
|
+
supports: () => false,
|
|
459
|
+
toggle: () => false,
|
|
460
|
+
[Symbol.iterator]: function* () { yield ''; return undefined; }
|
|
461
|
+
};
|
|
462
|
+
this.hreflang = '';
|
|
463
|
+
this.type = '';
|
|
464
|
+
this.text = '';
|
|
465
|
+
this.referrerPolicy = '';
|
|
466
|
+
this.origin = '';
|
|
467
|
+
this.protocol = '';
|
|
468
|
+
this.username = '';
|
|
469
|
+
this.password = '';
|
|
470
|
+
this.host = '';
|
|
471
|
+
this.hostname = '';
|
|
472
|
+
this.port = '';
|
|
473
|
+
this.pathname = '';
|
|
474
|
+
this.search = '';
|
|
475
|
+
this.hash = '';
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DOMWindow } from 'jsdom';
|
|
2
|
+
export interface DOMSettableTokenList {
|
|
3
|
+
length: number;
|
|
4
|
+
value: string;
|
|
5
|
+
add(token: string): void;
|
|
6
|
+
contains(token: string): boolean;
|
|
7
|
+
item(index: number): string | null;
|
|
8
|
+
remove(token: string): void;
|
|
9
|
+
replace(oldToken: string, newToken: string): boolean;
|
|
10
|
+
supports(token: string): boolean;
|
|
11
|
+
toggle(token: string, force?: boolean): boolean;
|
|
12
|
+
[Symbol.iterator](): Iterator<string>;
|
|
13
|
+
}
|
|
14
|
+
export declare function setupBaseElements(window: DOMWindow): void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function setupBaseElements(window) {
|
|
2
|
+
// Define DOMSettableTokenList
|
|
3
|
+
const DOMSettableTokenListClass = class {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.length = 0;
|
|
6
|
+
this.value = '';
|
|
7
|
+
}
|
|
8
|
+
add(token) { }
|
|
9
|
+
contains(token) { return false; }
|
|
10
|
+
item(index) { return null; }
|
|
11
|
+
remove(token) { }
|
|
12
|
+
replace(oldToken, newToken) { return false; }
|
|
13
|
+
supports(token) { return false; }
|
|
14
|
+
toggle(token, force) { return false; }
|
|
15
|
+
[Symbol.iterator]() {
|
|
16
|
+
return function* () { yield ''; return undefined; }();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// Define globally
|
|
20
|
+
globalThis.DOMSettableTokenList = DOMSettableTokenListClass;
|
|
21
|
+
// Define SVGElement globally
|
|
22
|
+
const SVGElementClass = class {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.id = '';
|
|
25
|
+
this.className = '';
|
|
26
|
+
this.style = {
|
|
27
|
+
cssText: '',
|
|
28
|
+
length: 0,
|
|
29
|
+
parentRule: null,
|
|
30
|
+
getPropertyPriority: () => '',
|
|
31
|
+
getPropertyValue: () => '',
|
|
32
|
+
item: () => '',
|
|
33
|
+
removeProperty: () => '',
|
|
34
|
+
setProperty: () => '',
|
|
35
|
+
[Symbol.iterator]: function* () { yield ''; return undefined; }
|
|
36
|
+
};
|
|
37
|
+
// ... rest of SVGElement implementation
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
// Define globally
|
|
41
|
+
globalThis.SVGElement = SVGElementClass;
|
|
42
|
+
// Assign to window if not already present
|
|
43
|
+
if (!window.SVGElement) {
|
|
44
|
+
window.SVGElement = SVGElementClass;
|
|
45
|
+
}
|
|
46
|
+
}
|