forked from b-fuze/deno-dom
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.ts
126 lines (108 loc) · 3.81 KB
/
api.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
export { nodesFromString } from "./deserialize.ts";
export * from "./dom/node.ts";
export * from "./dom/element.ts";
export * from "./dom/document.ts";
export * from "./dom/document-fragment.ts";
export * from "./dom/dom-parser.ts";
export * from "./dom/html-elements/html-template-element.ts";
export { disableCodeGeneration as denoDomDisableQuerySelectorCodeGeneration } from "./dom/selectors/selectors.ts";
// custom elements
export * from "./dom/elements/svg-element.ts"
export * from "./dom/elements/math-ml-element.ts"
export * from "./dom/document-fragment.ts"
export * from "./dom/html-elements/html-form-element.ts"
export * from "./dom/html-elements/html-media-element.ts"
export * from "./dom/html-elements/html-video-element.ts"
export * from "./dom/html-elements/html-input-element.ts"
export * from "./dom/html-elements/html-heading-element.ts"
export * from "./dom/html-elements/html-image-element.ts"
export * from "./dom/html-elements/html-button-element.ts"
export * from "./dom/html-elements/html-div-element.ts"
export * from "./dom/html-elements/html-dialog-element.ts"
export * from "./dom/html-elements/html-option-element.ts"
export * from "./dom/html-elements/html-select-element.ts"
export * from "./dom/mutation-observer.ts"
// Re-export private constructors without constructor signature
import {
CharacterData as ConstructibleCharacterData,
Node as ConstructibleNode,
} from "./dom/node.ts";
import { HTMLDocument as ConstructibleHTMLDocument } from "./dom/document.ts";
import { HTMLElement as ConstructibleHTMLElement } from "./dom/elements/html-element.ts"
import {
Attr as ConstructibleAttr,
Element as ConstructibleElement,
} from "./dom/element.ts";
export const Node:
& Pick<
typeof ConstructibleNode,
keyof typeof ConstructibleNode
>
& Function = ConstructibleNode;
export type Node = ConstructibleNode;
export const HTMLDocument:
& Pick<
typeof ConstructibleHTMLDocument,
keyof typeof ConstructibleHTMLDocument
>
& Function = ConstructibleHTMLDocument;
export type HTMLDocument = ConstructibleHTMLDocument;
export const CharacterData:
& Pick<
typeof ConstructibleCharacterData,
keyof typeof ConstructibleCharacterData
>
& Function = ConstructibleCharacterData;
export type CharacterData = ConstructibleCharacterData;
export const Element:
& Pick<
typeof ConstructibleElement,
keyof typeof ConstructibleElement
>
& Function = ConstructibleElement;
export type Element = ConstructibleElement;
export const HTMLElement:
& Pick<
typeof ConstructibleHTMLElement,
keyof typeof ConstructibleHTMLElement
>
& Function & {new(): ConstructibleHTMLElement} = ConstructibleHTMLElement;
export type HTMLElement = ConstructibleHTMLElement;
export const Attr:
& Pick<
typeof ConstructibleAttr,
keyof typeof ConstructibleAttr
>
& Function = ConstructibleAttr;
export type Attr = ConstructibleAttr;
export { NodeListPublic as NodeList } from "./dom/node-list.ts";
export { HTMLCollectionPublic as HTMLCollection } from "./dom/html-collection.ts";
import { NodeList } from "./dom/node-list.ts";
import { HTMLCollection } from "./dom/html-collection.ts";
// Prevent childNodes and HTMLCollections from being seen as an arrays
const oldHasInstance = Array[Symbol.hasInstance];
Object.defineProperty(Array, Symbol.hasInstance, {
value(value: any): boolean {
switch (value?.constructor) {
case HTMLCollection:
case NodeList:
return false;
default:
return oldHasInstance.call(this, value);
}
},
configurable: true,
});
const oldIsArray = Array.isArray;
Object.defineProperty(Array, "isArray", {
value: (value: any): boolean => {
switch (value?.constructor) {
case HTMLCollection:
case NodeList:
return false;
default:
return oldIsArray.call(Array, value);
}
},
configurable: true,
});