index.d.ts 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  1. declare const createAttributeProxy: (caseInsensitive: boolean) => any;
  2. declare class MockAttributeMap {
  3. caseInsensitive: boolean;
  4. constructor(caseInsensitive?: boolean);
  5. get length(): number;
  6. item(index: number): MockAttr;
  7. setNamedItem(attr: MockAttr): void;
  8. setNamedItemNS(attr: MockAttr): void;
  9. getNamedItem(attrName: string): MockAttr;
  10. getNamedItemNS(namespaceURI: string | null, attrName: string): MockAttr;
  11. removeNamedItem(attr: MockAttr): void;
  12. removeNamedItemNS(attr: MockAttr): void;
  13. [Symbol.iterator](): {
  14. next: () => {
  15. done: boolean;
  16. value: MockAttr;
  17. };
  18. };
  19. get [Symbol.toStringTag](): string;
  20. }
  21. declare function cloneAttributes(srcAttrs: MockAttributeMap, sortByName?: boolean): MockAttributeMap;
  22. declare class MockAttr {
  23. constructor(attrName: string, attrValue: string, namespaceURI?: string | null);
  24. get name(): string;
  25. set name(value: string);
  26. get value(): string;
  27. set value(value: string);
  28. get nodeName(): string;
  29. set nodeName(value: string);
  30. get nodeValue(): string;
  31. set nodeValue(value: string);
  32. get namespaceURI(): string;
  33. set namespaceURI(namespaceURI: string);
  34. }
  35. declare class MockClassList {
  36. constructor(elm: HTMLElement);
  37. add(...classNames: string[]): void;
  38. remove(...classNames: string[]): void;
  39. contains(className: string): boolean;
  40. toggle(className: string): void;
  41. get length(): number;
  42. item(index: number): string;
  43. toString(): string;
  44. }
  45. declare class MockComment extends MockNode {
  46. constructor(ownerDocument: any, data: string);
  47. cloneNode(_deep?: boolean): MockComment;
  48. get textContent(): string;
  49. set textContent(text: string);
  50. }
  51. declare function createConsole(): any;
  52. declare const enum NODE_TYPES {
  53. ELEMENT_NODE = 1,
  54. ATTRIBUTE_NODE = 2,
  55. TEXT_NODE = 3,
  56. CDATA_SECTION_NODE = 4,
  57. ENTITY_REFERENCE_NODE = 5,
  58. ENTITY_NODE = 6,
  59. PROCESSING_INSTRUCTION_NODE = 7,
  60. COMMENT_NODE = 8,
  61. DOCUMENT_NODE = 9,
  62. DOCUMENT_TYPE_NODE = 10,
  63. DOCUMENT_FRAGMENT_NODE = 11,
  64. NOTATION_NODE = 12
  65. }
  66. declare const enum NODE_NAMES {
  67. COMMENT_NODE = "#comment",
  68. DOCUMENT_NODE = "#document",
  69. DOCUMENT_FRAGMENT_NODE = "#document-fragment",
  70. TEXT_NODE = "#text"
  71. }
  72. declare class MockCSSStyleDeclaration {
  73. setProperty(prop: string, value: string): void;
  74. getPropertyValue(prop: string): string;
  75. removeProperty(prop: string): void;
  76. get length(): number;
  77. get cssText(): string;
  78. set cssText(cssText: string);
  79. }
  80. declare function createCSSStyleDeclaration(): MockCSSStyleDeclaration;
  81. declare class MockCSSRule {
  82. parentStyleSheet: MockCSSStyleSheet;
  83. cssText: string;
  84. type: number;
  85. constructor(parentStyleSheet: MockCSSStyleSheet);
  86. }
  87. declare class MockCSSStyleSheet {
  88. ownerNode: any;
  89. type: string;
  90. parentStyleSheet: MockCSSStyleSheet;
  91. cssRules: MockCSSRule[];
  92. constructor(ownerNode: MockStyleElement);
  93. get rules(): MockCSSRule[];
  94. set rules(rules: MockCSSRule[]);
  95. deleteRule(index: number): void;
  96. insertRule(rule: string, index?: number): number;
  97. }
  98. declare function getStyleElementText(styleElm: MockStyleElement): string;
  99. declare function setStyleElementText(styleElm: MockStyleElement, text: string): void;
  100. declare class MockCustomElementRegistry implements CustomElementRegistry {
  101. constructor(win: Window);
  102. define(tagName: string, cstr: any, options?: any): void;
  103. get(tagName: string): any;
  104. getName(cstr: CustomElementConstructor): string;
  105. upgrade(_rootNode: any): void;
  106. clear(): void;
  107. whenDefined(tagName: string): Promise<CustomElementConstructor>;
  108. }
  109. declare function createCustomElement(customElements: MockCustomElementRegistry, ownerDocument: any, tagName: string): any;
  110. declare function connectNode(ownerDocument: any, node: MockNode): void;
  111. declare function disconnectNode(node: MockNode): void;
  112. declare function attributeChanged(node: MockNode, attrName: string, oldValue: string | null, newValue: string | null): void;
  113. declare function checkAttributeChanged(node: MockNode): boolean;
  114. declare function dataset(elm: MockElement): any;
  115. declare class MockDocumentFragment extends MockHTMLElement {
  116. constructor(ownerDocument: any);
  117. getElementById(id: string): MockElement;
  118. cloneNode(deep?: boolean): MockDocumentFragment;
  119. }
  120. declare class MockDocumentTypeNode extends MockHTMLElement {
  121. constructor(ownerDocument: any);
  122. }
  123. declare class MockDocument extends MockHTMLElement {
  124. defaultView: any;
  125. cookie: string;
  126. referrer: string;
  127. constructor(html?: string | boolean | null, win?: any);
  128. get dir(): string;
  129. set dir(value: string);
  130. get localName(): never;
  131. get location(): Location;
  132. set location(val: Location);
  133. get baseURI(): string;
  134. get URL(): string;
  135. get styleSheets(): any;
  136. get scripts(): any;
  137. get forms(): any;
  138. get images(): any;
  139. get scrollingElement(): MockHTMLElement | MockElement;
  140. get documentElement(): MockHTMLElement | MockElement;
  141. set documentElement(documentElement: MockHTMLElement | MockElement);
  142. get head(): MockHTMLElement | MockElement;
  143. set head(head: MockHTMLElement | MockElement);
  144. get body(): MockHTMLElement | MockElement;
  145. set body(body: MockHTMLElement | MockElement);
  146. appendChild(newNode: MockElement): MockElement;
  147. createComment(data: string): MockComment;
  148. createAttribute(attrName: string): MockAttr;
  149. createAttributeNS(namespaceURI: string, attrName: string): MockAttr;
  150. createElement(tagName: string): any;
  151. createElementNS(namespaceURI: string, tagName: string): any;
  152. createTextNode(text: string): MockTextNode;
  153. createDocumentFragment(): MockDocumentFragment;
  154. createDocumentTypeNode(): MockDocumentTypeNode;
  155. getElementById(id: string): MockElement;
  156. getElementsByName(elmName: string): MockElement[];
  157. get title(): string;
  158. set title(value: string);
  159. }
  160. declare function createDocument(html?: string | boolean): Document;
  161. declare function createFragment(html?: string): DocumentFragment;
  162. declare function resetDocument(doc: Document): void;
  163. declare function getElementById(elm: MockElement, id: string): MockElement;
  164. declare function setOwnerDocument(elm: MockElement, ownerDocument: any): void;
  165. declare function createElement(ownerDocument: any, tagName: string): any;
  166. declare function createElementNS(ownerDocument: any, namespaceURI: string, tagName: string): any;
  167. declare class MockAnchorElement extends MockHTMLElement {
  168. constructor(ownerDocument: any);
  169. get href(): string;
  170. set href(value: string);
  171. get pathname(): string;
  172. }
  173. declare class MockButtonElement extends MockHTMLElement {
  174. constructor(ownerDocument: any);
  175. }
  176. declare class MockImageElement extends MockHTMLElement {
  177. constructor(ownerDocument: any);
  178. get draggable(): boolean;
  179. set draggable(value: boolean);
  180. get src(): string;
  181. set src(value: string);
  182. }
  183. declare class MockInputElement extends MockHTMLElement {
  184. constructor(ownerDocument: any);
  185. get list(): HTMLElement;
  186. }
  187. declare class MockFormElement extends MockHTMLElement {
  188. constructor(ownerDocument: any);
  189. }
  190. declare class MockLinkElement extends MockHTMLElement {
  191. constructor(ownerDocument: any);
  192. get href(): string;
  193. set href(value: string);
  194. }
  195. declare class MockMetaElement extends MockHTMLElement {
  196. content: string;
  197. constructor(ownerDocument: any);
  198. }
  199. declare class MockScriptElement extends MockHTMLElement {
  200. constructor(ownerDocument: any);
  201. get src(): string;
  202. set src(value: string);
  203. }
  204. declare class MockDOMMatrix {
  205. static fromMatrix(): MockDOMMatrix;
  206. a: number;
  207. b: number;
  208. c: number;
  209. d: number;
  210. e: number;
  211. f: number;
  212. m11: number;
  213. m12: number;
  214. m13: number;
  215. m14: number;
  216. m21: number;
  217. m22: number;
  218. m23: number;
  219. m24: number;
  220. m31: number;
  221. m32: number;
  222. m33: number;
  223. m34: number;
  224. m41: number;
  225. m42: number;
  226. m43: number;
  227. m44: number;
  228. is2D: boolean;
  229. isIdentity: boolean;
  230. inverse(): MockDOMMatrix;
  231. flipX(): MockDOMMatrix;
  232. flipY(): MockDOMMatrix;
  233. multiply(): MockDOMMatrix;
  234. rotate(): MockDOMMatrix;
  235. rotateAxisAngle(): MockDOMMatrix;
  236. rotateFromVector(): MockDOMMatrix;
  237. scale(): MockDOMMatrix;
  238. scaleNonUniform(): MockDOMMatrix;
  239. skewX(): MockDOMMatrix;
  240. skewY(): MockDOMMatrix;
  241. toJSON(): void;
  242. toString(): void;
  243. transformPoint(): MockDOMPoint;
  244. translate(): MockDOMMatrix;
  245. }
  246. declare class MockDOMPoint {
  247. w: number;
  248. x: number;
  249. y: number;
  250. z: number;
  251. toJSON(): void;
  252. matrixTransform(): MockDOMMatrix;
  253. }
  254. declare class MockSVGRect {
  255. height: number;
  256. width: number;
  257. x: number;
  258. y: number;
  259. }
  260. declare class MockStyleElement extends MockHTMLElement {
  261. sheet: MockCSSStyleSheet;
  262. constructor(ownerDocument: any);
  263. get innerHTML(): string;
  264. set innerHTML(value: string);
  265. get innerText(): string;
  266. set innerText(value: string);
  267. get textContent(): string;
  268. set textContent(value: string);
  269. }
  270. declare class MockSVGElement extends MockElement {
  271. get ownerSVGElement(): SVGSVGElement;
  272. get viewportElement(): SVGElement;
  273. onunload(): void;
  274. get pathLength(): number;
  275. isPointInFill(_pt: DOMPoint): boolean;
  276. isPointInStroke(_pt: DOMPoint): boolean;
  277. getTotalLength(): number;
  278. }
  279. declare class MockSVGGraphicsElement extends MockSVGElement {
  280. getBBox(_options?: {
  281. clipped: boolean;
  282. fill: boolean;
  283. markers: boolean;
  284. stroke: boolean;
  285. }): MockSVGRect;
  286. getCTM(): MockDOMMatrix;
  287. getScreenCTM(): MockDOMMatrix;
  288. }
  289. declare class MockSVGSVGElement extends MockSVGGraphicsElement {
  290. createSVGPoint(): MockDOMPoint;
  291. }
  292. declare class MockSVGTextContentElement extends MockSVGGraphicsElement {
  293. getComputedTextLength(): number;
  294. }
  295. declare class MockBaseElement extends MockHTMLElement {
  296. constructor(ownerDocument: any);
  297. get href(): string;
  298. set href(value: string);
  299. }
  300. declare class MockTemplateElement extends MockHTMLElement {
  301. content: MockDocumentFragment;
  302. constructor(ownerDocument: any);
  303. get innerHTML(): string;
  304. set innerHTML(html: string);
  305. cloneNode(deep?: boolean): MockTemplateElement;
  306. }
  307. declare class MockTitleElement extends MockHTMLElement {
  308. constructor(ownerDocument: any);
  309. get text(): string;
  310. set text(value: string);
  311. }
  312. declare class MockUListElement extends MockHTMLElement {
  313. constructor(ownerDocument: any);
  314. }
  315. type CanvasContext = '2d' | 'webgl' | 'webgl2' | 'bitmaprenderer';
  316. declare class CanvasRenderingContext {
  317. context: CanvasContext;
  318. contextAttributes: WebGLContextAttributes;
  319. constructor(context: CanvasContext, contextAttributes?: WebGLContextAttributes);
  320. fillRect(): void;
  321. clearRect(): void;
  322. getImageData(_: number, __: number, w: number, h: number): {
  323. data: any[];
  324. };
  325. toDataURL(): string;
  326. putImageData(): void;
  327. createImageData(): ImageData;
  328. setTransform(): void;
  329. drawImage(): void;
  330. save(): void;
  331. fillText(): void;
  332. restore(): void;
  333. beginPath(): void;
  334. moveTo(): void;
  335. lineTo(): void;
  336. closePath(): void;
  337. stroke(): void;
  338. translate(): void;
  339. scale(): void;
  340. rotate(): void;
  341. arc(): void;
  342. fill(): void;
  343. measureText(): {
  344. width: number;
  345. };
  346. transform(): void;
  347. rect(): void;
  348. clip(): void;
  349. }
  350. declare class MockCanvasElement extends MockHTMLElement {
  351. constructor(ownerDocument: any);
  352. getContext(context: CanvasContext, contextAttributes?: WebGLContextAttributes): CanvasRenderingContext;
  353. }
  354. declare class MockEvent {
  355. bubbles: boolean;
  356. cancelBubble: boolean;
  357. cancelable: boolean;
  358. composed: boolean;
  359. currentTarget: MockElement;
  360. defaultPrevented: boolean;
  361. srcElement: MockElement;
  362. target: MockElement;
  363. timeStamp: number;
  364. type: string;
  365. constructor(type: string, eventInitDict?: EventInit);
  366. preventDefault(): void;
  367. stopPropagation(): void;
  368. stopImmediatePropagation(): void;
  369. /**
  370. * @ref https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath
  371. * @returns a composed path of the event
  372. */
  373. composedPath(): MockElement[];
  374. }
  375. declare class MockCustomEvent extends MockEvent {
  376. detail: any;
  377. constructor(type: string, customEventInitDic?: CustomEventInit);
  378. }
  379. declare class MockKeyboardEvent extends MockEvent {
  380. code: string;
  381. key: string;
  382. altKey: boolean;
  383. ctrlKey: boolean;
  384. metaKey: boolean;
  385. shiftKey: boolean;
  386. location: number;
  387. repeat: boolean;
  388. constructor(type: string, keyboardEventInitDic?: KeyboardEventInit);
  389. }
  390. declare class MockMouseEvent extends MockEvent {
  391. screenX: number;
  392. screenY: number;
  393. clientX: number;
  394. clientY: number;
  395. ctrlKey: boolean;
  396. shiftKey: boolean;
  397. altKey: boolean;
  398. metaKey: boolean;
  399. button: number;
  400. buttons: number;
  401. relatedTarget: EventTarget;
  402. constructor(type: string, mouseEventInitDic?: MouseEventInit);
  403. }
  404. declare class MockUIEvent extends MockEvent {
  405. detail: number | null;
  406. view: MockWindow | null;
  407. constructor(type: string, uiEventInitDic?: UIEventInit);
  408. }
  409. declare class MockFocusEvent extends MockUIEvent {
  410. relatedTarget: EventTarget | null;
  411. constructor(type: 'blur' | 'focus', focusEventInitDic?: FocusEventInit);
  412. }
  413. declare class MockEventListener {
  414. type: string;
  415. handler: (ev?: any) => void;
  416. constructor(type: string, handler: any);
  417. }
  418. declare function addEventListener(elm: any, type: string, handler: any): void;
  419. declare function removeEventListener(elm: any, type: string, handler: any): void;
  420. declare function resetEventListeners(target: any): void;
  421. declare function dispatchEvent(currentTarget: any, ev: MockEvent): boolean;
  422. interface EventTarget {
  423. }
  424. declare function setupGlobal(gbl: any): any;
  425. declare function teardownGlobal(gbl: any): void;
  426. declare function patchWindow(winToBePatched: any): void;
  427. declare function addGlobalsToWindowPrototype(mockWinPrototype: any): void;
  428. declare class MockHeaders {
  429. constructor(init?: string[][] | Map<string, string> | any);
  430. append(key: string, value: string): void;
  431. delete(key: string): void;
  432. entries(): any;
  433. forEach(cb: (value: string, key: string) => void): void;
  434. get(key: string): string;
  435. has(key: string): boolean;
  436. keys(): {
  437. next(): {
  438. value: string;
  439. done: boolean;
  440. };
  441. [Symbol.iterator](): any;
  442. };
  443. set(key: string, value: string): void;
  444. values(): any;
  445. [Symbol.iterator](): any;
  446. }
  447. declare class MockHistory {
  448. get length(): number;
  449. back(): void;
  450. forward(): void;
  451. go(_value: number): void;
  452. pushState(_state: any, _title: string, _url: string): void;
  453. replaceState(_state: any, _title: string, _url: string): void;
  454. }
  455. declare class MockIntersectionObserver {
  456. constructor();
  457. disconnect(): void;
  458. observe(): void;
  459. takeRecords(): any[];
  460. unobserve(): void;
  461. }
  462. declare class MockLocation implements Location {
  463. ancestorOrigins: any;
  464. protocol: string;
  465. host: string;
  466. hostname: string;
  467. port: string;
  468. pathname: string;
  469. search: string;
  470. hash: string;
  471. username: string;
  472. password: string;
  473. origin: string;
  474. get href(): string;
  475. set href(value: string);
  476. assign(_url: string): void;
  477. reload(_forcedReload?: boolean): void;
  478. replace(_url: string): void;
  479. toString(): string;
  480. }
  481. declare class MockNavigator {
  482. appCodeName: string;
  483. appName: string;
  484. appVersion: string;
  485. platform: string;
  486. userAgent: string;
  487. }
  488. declare class MockNode {
  489. nodeName: string | null;
  490. nodeType: number;
  491. ownerDocument: any;
  492. parentNode: MockNode | null;
  493. childNodes: MockNode[];
  494. constructor(ownerDocument: any, nodeType: number, nodeName: string | null, nodeValue: string | null);
  495. appendChild(newNode: MockNode): MockNode;
  496. append(...items: (MockNode | string)[]): void;
  497. prepend(...items: (MockNode | string)[]): void;
  498. cloneNode(deep?: boolean): MockNode;
  499. compareDocumentPosition(_other: MockNode): number;
  500. get firstChild(): MockNode | null;
  501. insertBefore(newNode: MockNode, referenceNode: MockNode): MockNode;
  502. get isConnected(): boolean;
  503. isSameNode(node: any): boolean;
  504. get lastChild(): MockNode | null;
  505. get nextSibling(): MockNode | null;
  506. get nodeValue(): string;
  507. set nodeValue(value: string);
  508. get parentElement(): any;
  509. set parentElement(value: any);
  510. get previousSibling(): MockNode | null;
  511. contains(otherNode: MockNode): boolean;
  512. removeChild(childNode: MockNode): MockNode;
  513. remove(): void;
  514. replaceChild(newChild: MockNode, oldChild: MockNode): MockNode;
  515. get textContent(): string;
  516. set textContent(value: string);
  517. static ELEMENT_NODE: number;
  518. static TEXT_NODE: number;
  519. static PROCESSING_INSTRUCTION_NODE: number;
  520. static COMMENT_NODE: number;
  521. static DOCUMENT_NODE: number;
  522. static DOCUMENT_TYPE_NODE: number;
  523. static DOCUMENT_FRAGMENT_NODE: number;
  524. }
  525. declare class MockNodeList {
  526. childNodes: MockNode[];
  527. length: number;
  528. ownerDocument: any;
  529. constructor(ownerDocument: any, childNodes: MockNode[], length: number);
  530. }
  531. type MockElementInternals = Record<keyof ElementInternals, null>;
  532. declare class MockElement extends MockNode {
  533. attachInternals(): MockElementInternals;
  534. constructor(ownerDocument: any, nodeName: string | null, namespaceURI?: string | null);
  535. addEventListener(type: string, handler: (ev?: any) => void): void;
  536. attachShadow(_opts: ShadowRootInit): any;
  537. blur(): void;
  538. get localName(): string;
  539. get namespaceURI(): string;
  540. get shadowRoot(): any;
  541. /**
  542. * Set shadow root for element
  543. * @param shadowRoot - ShadowRoot to set
  544. */
  545. set shadowRoot(shadowRoot: any);
  546. get attributes(): MockAttributeMap;
  547. set attributes(attrs: MockAttributeMap);
  548. get children(): MockElement[];
  549. get childElementCount(): number;
  550. get className(): string;
  551. set className(value: string);
  552. get classList(): MockClassList;
  553. click(): void;
  554. cloneNode(_deep?: boolean): MockElement;
  555. closest(selector: string): this;
  556. get dataset(): any;
  557. get dir(): string;
  558. set dir(value: string);
  559. dispatchEvent(ev: MockEvent): boolean;
  560. get firstElementChild(): MockElement | null;
  561. focus(_options?: {
  562. preventScroll?: boolean;
  563. }): void;
  564. getAttribute(attrName: string): any;
  565. getAttributeNS(namespaceURI: string | null, attrName: string): string;
  566. getAttributeNode(attrName: string): MockAttr | null;
  567. getBoundingClientRect(): {
  568. bottom: number;
  569. height: number;
  570. left: number;
  571. right: number;
  572. top: number;
  573. width: number;
  574. x: number;
  575. y: number;
  576. };
  577. getRootNode(opts?: {
  578. composed?: boolean;
  579. [key: string]: any;
  580. }): Node;
  581. get draggable(): boolean;
  582. set draggable(value: boolean);
  583. hasChildNodes(): boolean;
  584. get id(): string;
  585. set id(value: string);
  586. get innerHTML(): string;
  587. set innerHTML(html: string);
  588. get innerText(): string;
  589. set innerText(value: string);
  590. insertAdjacentElement(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', elm: MockHTMLElement): MockHTMLElement;
  591. insertAdjacentHTML(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', html: string): void;
  592. insertAdjacentText(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', text: string): void;
  593. hasAttribute(attrName: string): boolean;
  594. hasAttributeNS(namespaceURI: string | null, name: string): boolean;
  595. get hidden(): boolean;
  596. set hidden(isHidden: boolean);
  597. get lang(): string;
  598. set lang(value: string);
  599. get lastElementChild(): MockElement | null;
  600. matches(selector: string): boolean;
  601. get nextElementSibling(): any;
  602. get outerHTML(): string;
  603. get previousElementSibling(): any;
  604. getElementsByClassName(classNames: string): MockElement[];
  605. getElementsByTagName(tagName: string): MockElement[];
  606. querySelector(selector: string): any;
  607. querySelectorAll(selector: string): any;
  608. removeAttribute(attrName: string): void;
  609. removeAttributeNS(namespaceURI: string | null, attrName: string): void;
  610. removeEventListener(type: string, handler: any): void;
  611. setAttribute(attrName: string, value: any): void;
  612. setAttributeNS(namespaceURI: string | null, attrName: string, value: any): void;
  613. get style(): any;
  614. set style(val: any);
  615. get tabIndex(): number;
  616. set tabIndex(value: number);
  617. get tagName(): string;
  618. set tagName(value: string);
  619. get textContent(): string;
  620. set textContent(value: string);
  621. get title(): string;
  622. set title(value: string);
  623. animate(): void;
  624. onanimationstart(): void;
  625. onanimationend(): void;
  626. onanimationiteration(): void;
  627. onabort(): void;
  628. onauxclick(): void;
  629. onbeforecopy(): void;
  630. onbeforecut(): void;
  631. onbeforepaste(): void;
  632. onblur(): void;
  633. oncancel(): void;
  634. oncanplay(): void;
  635. oncanplaythrough(): void;
  636. onchange(): void;
  637. onclick(): void;
  638. onclose(): void;
  639. oncontextmenu(): void;
  640. oncopy(): void;
  641. oncuechange(): void;
  642. oncut(): void;
  643. ondblclick(): void;
  644. ondrag(): void;
  645. ondragend(): void;
  646. ondragenter(): void;
  647. ondragleave(): void;
  648. ondragover(): void;
  649. ondragstart(): void;
  650. ondrop(): void;
  651. ondurationchange(): void;
  652. onemptied(): void;
  653. onended(): void;
  654. onerror(): void;
  655. onfocus(): void;
  656. onfocusin(): void;
  657. onfocusout(): void;
  658. onformdata(): void;
  659. onfullscreenchange(): void;
  660. onfullscreenerror(): void;
  661. ongotpointercapture(): void;
  662. oninput(): void;
  663. oninvalid(): void;
  664. onkeydown(): void;
  665. onkeypress(): void;
  666. onkeyup(): void;
  667. onload(): void;
  668. onloadeddata(): void;
  669. onloadedmetadata(): void;
  670. onloadstart(): void;
  671. onlostpointercapture(): void;
  672. onmousedown(): void;
  673. onmouseenter(): void;
  674. onmouseleave(): void;
  675. onmousemove(): void;
  676. onmouseout(): void;
  677. onmouseover(): void;
  678. onmouseup(): void;
  679. onmousewheel(): void;
  680. onpaste(): void;
  681. onpause(): void;
  682. onplay(): void;
  683. onplaying(): void;
  684. onpointercancel(): void;
  685. onpointerdown(): void;
  686. onpointerenter(): void;
  687. onpointerleave(): void;
  688. onpointermove(): void;
  689. onpointerout(): void;
  690. onpointerover(): void;
  691. onpointerup(): void;
  692. onprogress(): void;
  693. onratechange(): void;
  694. onreset(): void;
  695. onresize(): void;
  696. onscroll(): void;
  697. onsearch(): void;
  698. onseeked(): void;
  699. onseeking(): void;
  700. onselect(): void;
  701. onselectstart(): void;
  702. onstalled(): void;
  703. onsubmit(): void;
  704. onsuspend(): void;
  705. ontimeupdate(): void;
  706. ontoggle(): void;
  707. onvolumechange(): void;
  708. onwaiting(): void;
  709. onwebkitfullscreenchange(): void;
  710. onwebkitfullscreenerror(): void;
  711. onwheel(): void;
  712. requestFullscreen(): void;
  713. scrollBy(): void;
  714. scrollTo(): void;
  715. scrollIntoView(): void;
  716. toString(opts?: SerializeNodeToHtmlOptions): string;
  717. }
  718. declare function resetElement(elm: MockElement): void;
  719. declare class MockHTMLElement extends MockElement {
  720. constructor(ownerDocument: any, nodeName: string | null);
  721. get tagName(): string;
  722. set tagName(value: string);
  723. /**
  724. * A node’s parent of type Element is known as its parent element.
  725. * If the node has a parent of a different type, its parent element
  726. * is null.
  727. * @returns MockElement
  728. */
  729. get parentElement(): any;
  730. get attributes(): MockAttributeMap;
  731. set attributes(attrs: MockAttributeMap);
  732. }
  733. declare class MockTextNode extends MockNode {
  734. constructor(ownerDocument: any, text: string);
  735. cloneNode(_deep?: boolean): MockTextNode;
  736. get textContent(): string;
  737. set textContent(text: string);
  738. get data(): string;
  739. set data(text: string);
  740. get wholeText(): string;
  741. }
  742. declare function parseHtmlToDocument(html: string, ownerDocument?: MockDocument): any;
  743. declare function parseHtmlToFragment(html: string, ownerDocument?: MockDocument): any;
  744. declare function parseDocumentUtil(ownerDocument: any, html: string): any;
  745. declare function parseFragmentUtil(ownerDocument: any, html: string): any;
  746. type DOMParserSupportedType = 'text/html' | 'text/xml' | 'application/xml' | 'application/xhtml+xml' | 'image/svg+xml';
  747. declare class MockDOMParser {
  748. parseFromString(htmlToParse: string, mimeType: DOMParserSupportedType): MockDocument;
  749. }
  750. /**
  751. * https://developer.mozilla.org/en-US/docs/Web/API/Performance
  752. */
  753. declare class MockPerformance implements Performance {
  754. timeOrigin: number;
  755. eventCounts: EventCounts;
  756. constructor();
  757. addEventListener(): void;
  758. clearMarks(): void;
  759. clearMeasures(): void;
  760. clearResourceTimings(): void;
  761. dispatchEvent(): boolean;
  762. getEntries(): any;
  763. getEntriesByName(): any;
  764. getEntriesByType(): any;
  765. mark(): PerformanceMark;
  766. measure(): PerformanceMeasure;
  767. get navigation(): any;
  768. now(): number;
  769. get onresourcetimingbufferfull(): any;
  770. removeEventListener(): void;
  771. setResourceTimingBufferSize(): void;
  772. get timing(): any;
  773. toJSON(): void;
  774. }
  775. declare function resetPerformance(perf: Performance): void;
  776. type MockRequestInfo = MockRequest | string;
  777. interface MockRequestInit {
  778. body?: any;
  779. cache?: string;
  780. credentials?: string;
  781. headers?: any;
  782. integrity?: string;
  783. keepalive?: boolean;
  784. method?: string;
  785. mode?: string;
  786. redirect?: string;
  787. referrer?: string;
  788. referrerPolicy?: string;
  789. }
  790. declare class MockRequest {
  791. bodyUsed: boolean;
  792. cache: string;
  793. credentials: string;
  794. headers: MockHeaders;
  795. integrity: string;
  796. keepalive: boolean;
  797. mode: string;
  798. redirect: string;
  799. referrer: string;
  800. referrerPolicy: string;
  801. constructor(input?: any, init?: MockRequestInit);
  802. get url(): string;
  803. set url(value: string);
  804. get method(): string;
  805. set method(value: string);
  806. clone(): MockRequest;
  807. }
  808. interface MockResponseInit {
  809. headers?: any;
  810. ok?: boolean;
  811. status?: number;
  812. statusText?: string;
  813. type?: string;
  814. url?: string;
  815. }
  816. declare class MockResponse {
  817. headers: MockHeaders;
  818. ok: boolean;
  819. status: number;
  820. statusText: string;
  821. type: string;
  822. url: string;
  823. constructor(body?: string, init?: MockResponseInit);
  824. json(): Promise<any>;
  825. text(): Promise<string>;
  826. clone(): MockResponse;
  827. }
  828. /**
  829. * Check whether an element of interest matches a given selector.
  830. *
  831. * @param selector the selector of interest
  832. * @param elm an element within which to find matching elements
  833. * @returns whether the element matches the selector
  834. */
  835. declare function matches(selector: string, elm: MockElement): boolean;
  836. /**
  837. * Select the first element that matches a given selector
  838. *
  839. * @param selector the selector of interest
  840. * @param elm the element within which to find a matching element
  841. * @returns the first matching element, or null if none is found
  842. */
  843. declare function selectOne(selector: string, elm: MockElement): any;
  844. /**
  845. * Select all elements that match a given selector
  846. *
  847. * @param selector the selector of interest
  848. * @param elm an element within which to find matching elements
  849. * @returns all matching elements
  850. */
  851. declare function selectAll(selector: string, elm: MockElement): any;
  852. /**
  853. * A manifest of selectors which are known to be problematic in jQuery. See
  854. * here to track implementation and support:
  855. * https://github.com/jquery/jquery/issues/5111
  856. */
  857. declare const PROBLEMATIC_SELECTORS: readonly [":scope", ":where", ":is"];
  858. /**
  859. * Serialize a node (either a DOM node or a mock-doc node) to an HTML string.
  860. * This operation is similar to `outerHTML` but allows for more control over the
  861. * serialization process. It is fully synchronous meaning that it will not
  862. * wait for a component to be fully rendered before serializing it. Use `streamToHtml`
  863. * for a streaming version of this function.
  864. *
  865. * @param elm the node to serialize
  866. * @param serializationOptions options to control serialization behavior
  867. * @returns an html string
  868. */
  869. declare function serializeNodeToHtml(elm: Node | MockNode, serializationOptions?: SerializeNodeToHtmlOptions): string;
  870. declare const NON_ESCAPABLE_CONTENT: Set<string>;
  871. /**
  872. * A list of whitespace sensitive tag names, such as `code`, `pre`, etc.
  873. */
  874. declare const WHITESPACE_SENSITIVE: Set<string>;
  875. declare const EMPTY_ELEMENTS: Set<string>;
  876. /**
  877. * Partially duplicate of https://github.com/ionic-team/stencil/blob/6017dad2cb6fe366242e2e0594f82c8e3a3b5d15/src/declarations/stencil-public-compiler.ts#L895
  878. * Types can't be imported in this documented as Eslint will not embed the types
  879. * in the d.ts file.
  880. */
  881. interface SerializeNodeToHtmlOptions {
  882. approximateLineWidth?: number;
  883. excludeTagContent?: string[];
  884. excludeTags?: string[];
  885. indentSpaces?: number;
  886. newLines?: boolean;
  887. outerHtml?: boolean;
  888. prettyHtml?: boolean;
  889. removeAttributeQuotes?: boolean;
  890. removeBooleanAttributeQuotes?: boolean;
  891. removeEmptyAttributes?: boolean;
  892. removeHtmlComments?: boolean;
  893. serializeShadowRoot?: boolean;
  894. fullDocument?: boolean;
  895. }
  896. declare class MockStorage {
  897. key(_value: number): void;
  898. getItem(key: string): string;
  899. setItem(key: string, value: string): void;
  900. removeItem(key: string): void;
  901. clear(): void;
  902. }
  903. declare const nativeClearInterval: typeof clearInterval;
  904. declare const nativeClearTimeout: typeof clearTimeout;
  905. declare const nativeSetInterval: typeof setInterval;
  906. declare const nativeSetTimeout: typeof setTimeout;
  907. declare class MockWindow {
  908. URL: typeof URL;
  909. console: Console;
  910. customElements: CustomElementRegistry;
  911. document: Document;
  912. performance: Performance;
  913. devicePixelRatio: number;
  914. innerHeight: number;
  915. innerWidth: number;
  916. pageXOffset: number;
  917. pageYOffset: number;
  918. screen: Screen;
  919. screenLeft: number;
  920. screenTop: number;
  921. screenX: number;
  922. screenY: number;
  923. scrollX: number;
  924. scrollY: number;
  925. CustomEvent: typeof MockCustomEvent;
  926. Event: typeof MockEvent;
  927. Headers: typeof MockHeaders;
  928. FocusEvent: typeof MockFocusEvent;
  929. KeyboardEvent: typeof MockKeyboardEvent;
  930. MouseEvent: typeof MockMouseEvent;
  931. constructor(html?: string | boolean);
  932. addEventListener(type: string, handler: (ev?: any) => void): void;
  933. alert(msg: string): void;
  934. blur(): any;
  935. cancelAnimationFrame(id: any): void;
  936. cancelIdleCallback(id: any): void;
  937. get CharacterData(): any;
  938. set CharacterData(charDataCstr: any);
  939. clearInterval(id: any): void;
  940. clearTimeout(id: any): void;
  941. close(): void;
  942. confirm(): boolean;
  943. get CSS(): {
  944. supports: () => boolean;
  945. };
  946. get Document(): any;
  947. set Document(docCstr: any);
  948. get DocumentFragment(): any;
  949. set DocumentFragment(docFragCstr: any);
  950. get DocumentType(): any;
  951. set DocumentType(docTypeCstr: any);
  952. get DOMTokenList(): any;
  953. set DOMTokenList(domTokenListCstr: any);
  954. dispatchEvent(ev: MockEvent): boolean;
  955. get Element(): any;
  956. fetch(input: any, init?: any): any;
  957. focus(): any;
  958. getComputedStyle(_: any): any;
  959. get globalThis(): this;
  960. get history(): any;
  961. set history(hsty: any);
  962. get JSON(): JSON;
  963. get HTMLElement(): any;
  964. set HTMLElement(htmlElementCstr: any);
  965. get IntersectionObserver(): typeof MockIntersectionObserver;
  966. get localStorage(): MockStorage;
  967. set localStorage(locStorage: MockStorage);
  968. get location(): MockLocation;
  969. set location(val: Location | string);
  970. matchMedia(media: string): {
  971. media: string;
  972. matches: boolean;
  973. addListener: (_handler: (ev?: any) => void) => void;
  974. removeListener: (_handler: (ev?: any) => void) => void;
  975. addEventListener: (_type: string, _handler: (ev?: any) => void) => void;
  976. removeEventListener: (_type: string, _handler: (ev?: any) => void) => void;
  977. dispatchEvent: (_ev: any) => void;
  978. onchange: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null;
  979. };
  980. get Node(): any;
  981. get NodeList(): any;
  982. get navigator(): any;
  983. set navigator(nav: any);
  984. get parent(): any;
  985. prompt(): string;
  986. open(): any;
  987. get origin(): string;
  988. removeEventListener(type: string, handler: any): void;
  989. requestAnimationFrame(callback: (timestamp: number) => void): number;
  990. requestIdleCallback(callback: (deadline: {
  991. didTimeout: boolean;
  992. timeRemaining: () => number;
  993. }) => void): number;
  994. scroll(_x?: number, _y?: number): void;
  995. scrollBy(_x?: number, _y?: number): void;
  996. scrollTo(_x?: number, _y?: number): void;
  997. get self(): this;
  998. get sessionStorage(): any;
  999. set sessionStorage(locStorage: any);
  1000. setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
  1001. setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
  1002. get top(): this;
  1003. get window(): this;
  1004. onanimationstart(): void;
  1005. onanimationend(): void;
  1006. onanimationiteration(): void;
  1007. onabort(): void;
  1008. onauxclick(): void;
  1009. onbeforecopy(): void;
  1010. onbeforecut(): void;
  1011. onbeforepaste(): void;
  1012. onblur(): void;
  1013. oncancel(): void;
  1014. oncanplay(): void;
  1015. oncanplaythrough(): void;
  1016. onchange(): void;
  1017. onclick(): void;
  1018. onclose(): void;
  1019. oncontextmenu(): void;
  1020. oncopy(): void;
  1021. oncuechange(): void;
  1022. oncut(): void;
  1023. ondblclick(): void;
  1024. ondrag(): void;
  1025. ondragend(): void;
  1026. ondragenter(): void;
  1027. ondragleave(): void;
  1028. ondragover(): void;
  1029. ondragstart(): void;
  1030. ondrop(): void;
  1031. ondurationchange(): void;
  1032. onemptied(): void;
  1033. onended(): void;
  1034. onerror(): void;
  1035. onfocus(): void;
  1036. onfocusin(): void;
  1037. onfocusout(): void;
  1038. onformdata(): void;
  1039. onfullscreenchange(): void;
  1040. onfullscreenerror(): void;
  1041. ongotpointercapture(): void;
  1042. oninput(): void;
  1043. oninvalid(): void;
  1044. onkeydown(): void;
  1045. onkeypress(): void;
  1046. onkeyup(): void;
  1047. onload(): void;
  1048. onloadeddata(): void;
  1049. onloadedmetadata(): void;
  1050. onloadstart(): void;
  1051. onlostpointercapture(): void;
  1052. onmousedown(): void;
  1053. onmouseenter(): void;
  1054. onmouseleave(): void;
  1055. onmousemove(): void;
  1056. onmouseout(): void;
  1057. onmouseover(): void;
  1058. onmouseup(): void;
  1059. onmousewheel(): void;
  1060. onpaste(): void;
  1061. onpause(): void;
  1062. onplay(): void;
  1063. onplaying(): void;
  1064. onpointercancel(): void;
  1065. onpointerdown(): void;
  1066. onpointerenter(): void;
  1067. onpointerleave(): void;
  1068. onpointermove(): void;
  1069. onpointerout(): void;
  1070. onpointerover(): void;
  1071. onpointerup(): void;
  1072. onprogress(): void;
  1073. onratechange(): void;
  1074. onreset(): void;
  1075. onresize(): void;
  1076. onscroll(): void;
  1077. onsearch(): void;
  1078. onseeked(): void;
  1079. onseeking(): void;
  1080. onselect(): void;
  1081. onselectstart(): void;
  1082. onstalled(): void;
  1083. onsubmit(): void;
  1084. onsuspend(): void;
  1085. ontimeupdate(): void;
  1086. ontoggle(): void;
  1087. onvolumechange(): void;
  1088. onwaiting(): void;
  1089. onwebkitfullscreenchange(): void;
  1090. onwebkitfullscreenerror(): void;
  1091. onwheel(): void;
  1092. }
  1093. declare function createWindow(html?: string | boolean): Window;
  1094. declare function cloneWindow(srcWin: Window, opts?: {
  1095. customElementProxy?: boolean;
  1096. }): MockWindow | null;
  1097. declare function cloneDocument(srcDoc: Document): Document;
  1098. /**
  1099. * Constrain setTimeout() to 1ms, but still async. Also
  1100. * only allow setInterval() to fire once, also constrained to 1ms.
  1101. * @param win the mock window instance to update
  1102. */
  1103. declare function constrainTimeouts(win: any): void;
  1104. export { MockAttr, MockAttributeMap, MockComment, MockCustomEvent, MockDocument, MockElement, MockHTMLElement, MockHeaders, MockKeyboardEvent, MockMouseEvent, MockNode, MockRequest, MockRequestInfo, MockRequestInit, MockResponse, MockResponseInit, MockTextNode, MockWindow, NODE_TYPES, SerializeNodeToHtmlOptions, cloneAttributes, cloneDocument, cloneWindow, constrainTimeouts, createDocument, createFragment, parseHtmlToDocument, parseHtmlToFragment, patchWindow, resetDocument, serializeNodeToHtml, setupGlobal, teardownGlobal }