-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
351 lines (254 loc) · 10.2 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
// / <reference path="./index.d.ts" />
// document.body.style.setProperty("--test", 2);
// // document.body.textContent = 3;
// const a = document.querySelector("sdfks > input[type=range].test#hi[no]:hover")
// const b = document.querySelector("svg#logo > filter:first-of-child feTurbulence:not([type=fractalNoise])")
// / <reference no-default-lib="true" />
// / <reference lib="ESNext" />
// / <reference lib="WebWorker" />
// / <reference lib="WebWorker.Iterable" />
/// <reference path="./index.d.ts" />
// / <reference path="./worker.d.ts" />
// onfetch
history.pushState({})
const ownKeys = (object: any) => {
const descriptors = Object.getOwnPropertyDescriptors(object);
for (const key of Reflect.ownKeys(descriptors)) {
console.log(key, descriptors[key])
}
}
self.addEventListener("fetch", (event) => {
});
customElements.define("a-b", class extends HTMLElement {
constructor() {
super()
};
static formAssociated = true
asdkfasdf = "a"
static disabledFeatures = ["internals"]
connectedCallback() {
return 5
};
adoptedCallback() {
}
});
self.onconnect
self.addEventListener("connect", e => {
})
const asdfa = () => 5;
asdfa.apply
const c = document.querySelector.apply(document, "canvas")
self.name
document.execCommand("bold");
let s = document.getSelection();
s.extend
document.body.addEventListener("input", function (event) {
event.inputType
this
})
document.addEventListener("input", event => { })
const input = document.createElement("input");
input.type = "text";
input.addEventListener("input", ({ target }) => {
target.value;
})
// self.addEventListener("fetch", (event) => {
// });
const $ = document.querySelector.bind(document);
const dialog = $("dialog[open]");
const asdfkjdf = Document.prototype.querySelector.call(document, "body.a");
const asdfkjdf2 = document.querySelector("body.a");
const a: Tuple<number, 3> = [3, 4, 5];
const element1 = document.querySelector("alskdfj a");
element1.querySelectorAll(":scope > li:nth-of-type(odd)")
window.SpeechRecognitionResult
const element = document.querySelector(".foo");
if (element.matches("img")) {
element.src = "https://bigrat.monster/media/bigrat.png";
} else if (element.matches("dialog[open]")) {
element.showModal();
} else if (element.matches("body > a#main-link[href]")) {
element.href = "https://youtube.be/dQw4w9WgXcQ";
} else if (element.matches<HTMLTextAreaElement>(".inputfield")) {
element.value = "Hello world!";
}
//////////////
declare const noice: Element;
if (noice.matches("a")) {
noice;
if (noice.matches("[href]")) {
noice;
} else {
noice.href = "";
}
} else {
noice;
}
if (noice.matches("a[disabled]")) {
noice;
} else {
noice;
}
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ATTRIBUTE);
walker.nextNode();
walker.root;
const walker2 = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
while (walker2.nextNode()) {
const currentNode = walker2.currentNode // `currentNode` now has type `Text`
}
document.body.textContent
const asdg = JSON.parse("sldkfjsldaf")
const parseFromString = DOMParser.prototype.parseFromString.bind(new DOMParser());
const parseHTML = Range.prototype.createContextualFragment.bind(new Range());
declare const test: HTMLAnchorElement;
if (test.matches("div")) {
test
} else {
test
}
const template = document.querySelector("template#my-element-template");
customElements.define("my-element", class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.append(template.content.cloneNode(true));
this.shadowRoot.addEventListener("pointerdown", (event) => {
console.log(event.pointerType); // `event` has type `PointerEvent`
});
}
});
type HypertextNode = string | [string, { [key: string]: any }, ...HypertextNode[]];
const hypertextNode: HypertextNode =
["div", { id: "parent" },
["div", { id: "first-child" }, "I'm the first child"],
["div", { id: "second-child" }, "I'm the second child"]
];
const { module, instance } = await WebAssembly.instantiateStreaming(await fetch("./test.wasm"));
document.documentElement.addEventListener("drop", (event) => {
const items = event.dataTransfer.items;
const [item] = items;
})
var custom = {};
var formatter = {
header: function (x) {
if (x === custom) {
return ["span", { "style": "background-color: #fcc" }, "Hello!"] as const;
} else {
return null;
}
},
hasBody: function (x) {
return x === custom;
},
body: function (x) {
var selfRef = ["object", { "object": custom }] as const;
return ["ol", {}, ["li", {}, "world!"], ["li", {}, selfRef]] as const;
}
};
window.devtoolsFormatters = [formatter];
let recursion = {};
window.devtoolsFormatters = [{
header: (object) => object === recursion ? ["span", { style: "border: 1px solid #888" }, "Hello!"] : null,
hasBody: Boolean,
body: (object) => ["ol", {}, ["li", {}, "world!"], ["li", {}, ["object", { object }]]],
}];
console.log(recursion);
const sgdjh = instance.exports.abc(3, 6, 7);
const sgdjht = instance.exports.myGlobal.value;
const sgdjsdfht = instance.exports.myMemory.buffer;
const sgasdfdjht = instance.exports.myTable.set;
document.caretRangeFromPoint
document.caretPositionFromPoint
document.elementFromPoint
document.elementsFromPoint
document.scrollingElement
CaretPosition
new DOMParser().parseFromString("asdf", "application/xhtml+xml");
new DOMParser().parseFromString("asdf", "application/xml");
new DOMParser().parseFromString("asdf", "image/svg+xml");
new DOMParser().parseFromString("asdf", "text/html");
new DOMParser().parseFromString("asdf", "text/xml");
const test20 = document.querySelector("q.c[a]:p.c[a]");
const test21 = document.querySelector("q[a]#i#i:p.c");
const test22 = document.querySelector("q#i.c[a][a]");
const test23 = document.querySelector("q:p#i:p#i");
const test24 = document.querySelector("q");
const test25 = document.querySelector("q.c");
const test26 = document.querySelector("q.c#i");
const test27 = document.querySelector("q#i.c");
const test28 = document.querySelector("math#i.c");
const test29 = document.querySelector("munderover.c#i");
const test1 = document.querySelector("html body > div ~ a * + portal.basdf.asdfasdf:has(b)");
const test2 = document.querySelector("b:hover");
const test3 = document.querySelector("ul[class^=a].b");
const test4 = document.querySelector("div#no");
const test5 = document.querySelector("input.basdf.asdfasdf");
const test6 = document.querySelector("canvas.basdf.asdfasdf");
const test7 = document.querySelector("body.basdf.asdfasdf");
const test8 = document.querySelector("x.b:hover");
const test9 = document.querySelector(":scope > input[type=radio][name=test].aa:nth-of-type(even)");
const test10 = document.querySelector(":scope > .foo [viewBox] foreignObject[xmlns] munderover.sum .fraction [href] .foo[displaystyle]");
const test11 = document.querySelector(":scope > .foo [viewBox] foreignObject[xmlns] .fraction");
const test12 = document.querySelector(":scope > .foo [vviewBox] .ffvoreignObject[xmlns] .fraction");
const test13 = document.querySelector(":scope > .foo");
const test14 = document.querySelector(".bar");
const test15 = document.querySelector(".bar .baz");
const test16 = document.querySelector("filter .noise");
document.querySelector(":scope > #logo-svg msubsup")
document.querySelector("math .fraction") // MathMLElement
document.querySelector("filter > .noise") // SVGElement
document.querySelector(":scope > #logo-svg foreignObject msubsup .power") // MathMLElement
const test30 = document.querySelector("a.askdjf.lsdjf")
const test31 = document.querySelector("portal:hover")
const test32 = document.querySelector("a.b:hover")
const test33 = document.querySelector("html body > div ~ a * + portal.basdf.asdfasdf:has(b)")
const test34 = document.querySelector("body a")
const test35 = document.querySelector("a .test")
const test36 = document.querySelector("input[type=range] ~ .text")
const test37 = document.querySelector("input[type=range] .text")
const test38 = document.querySelector("input .text")
const test39 = document.querySelector("b .test")
document.querySelector(".parameter-chooser > label > input[type=radio][name=parameter] ~ .text");
let kasdf: BetterTypeScript.SelectorContainsSVGOrMathMLElement<"a math svg munderover.a img[src]">;
let kasdfsdf: BetterTypeScript.GetElementTypeFromSimpleSelector<".bar">;
let kasdfsdsdf: BetterTypeScript.SelectorContainsSVGOrMathMLElement<".bar .baz">;
let alskdfl: BetterTypeScript.SelectorStringContainingElementName = "alsdjfl.a a.b laksdfj";
type asdf = BetterTypeScript.SelectorContainsSVGOrMathMLElement<"span .test", BetterTypeScript.ElementNamespace.SVG>
type asd3f = BetterTypeScript.SelectorContainsSVGOrMathMLElement<"span .test">
type asdfdfds = BetterTypeScript.GetElementTypeFromSimpleSelector<"span">
type asdfdfdssdf = HTMLSpanElement extends MathMLElement ? 1 : 0;
type asdfdfdssdfsd = HTMLInputElement extends MathMLElement ? 1 : 0;
type asdfdfdssdf4 = MathMLElement extends HTMLSpanElement ? 1 : 0;
type asdfdfdssdf4sdf = MathMLElement["constructor"]["name"];
const string = Object.prototype.toString.apply({})
// OffscreenCanvas
// const element = document.querySelector("b");
// // const element = document.querySelector("a");
// if (element instanceof HTMLAnchorElement) {
// element.href
// } else if (element instanceof HTMLInputElement) {
// element.value
// }
// if (element.matches("a")) {
// element.href;
// }
// // const _self = self as unknown as ServiceWorkerGlobalScope;
// window.addEventListener("pointermove", (event) => {
// document.documentElement.style.setProperty("--mouse-x", event.clientX);
// document.documentElement.style.setProperty("--mouse-y", event.clientY);
// });
// const anchorTemplate = document.createElement("a");
// anchorTemplate.href = "https://example.com";
// anchorTemplate.textContent = "example";
// const anchorClone = anchorTemplate.cloneNode(true);
// importScripts("s")
// document
// const fragment = document.querySelector<HTMLTemplateElement>("template#foo-template").content;
// for (let i = 0; i < 10; i++) {
// const clone = fragment.cloneNode(true); // `clone` now has the type `DocumentFragment` instead of just `Node`
// clone.querySelector("a.destination").href = "https://example.com";
// document.body.append(clone);
// }
// const c = new OffscreenCanvas(1, 1);
// const ctx = c.getContext("2d", { alpha: true });
export { };