mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #51657 [jsdom] Use base.d.ts file by @ExE-Boss
This commit is contained in:
442
types/jsdom/base.d.ts
vendored
Normal file
442
types/jsdom/base.d.ts
vendored
Normal file
@@ -0,0 +1,442 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import { EventEmitter } from "events";
|
||||
import { ElementLocation } from "parse5";
|
||||
import { Context } from "vm";
|
||||
import * as tough from "tough-cookie";
|
||||
|
||||
// Needed to allow adding properties to `DOMWindow` that are only supported
|
||||
// in newer TypeScript versions:
|
||||
// tslint:disable-next-line: no-declare-current-package no-single-declare-module
|
||||
declare module "jsdom" {
|
||||
const toughCookie: typeof tough;
|
||||
class CookieJar extends tough.CookieJar {}
|
||||
|
||||
class JSDOM {
|
||||
constructor(html?: string | Buffer | BinaryData, options?: ConstructorOptions);
|
||||
|
||||
static fromURL(url: string, options?: BaseOptions): Promise<JSDOM>;
|
||||
static fromFile(url: string, options?: FileOptions): Promise<JSDOM>;
|
||||
static fragment(html: string): DocumentFragment;
|
||||
|
||||
readonly window: DOMWindow;
|
||||
readonly virtualConsole: VirtualConsole;
|
||||
readonly cookieJar: CookieJar;
|
||||
|
||||
/**
|
||||
* The serialize() method will return the HTML serialization of the document, including the doctype.
|
||||
*/
|
||||
serialize(): string;
|
||||
|
||||
/**
|
||||
* The nodeLocation() method will find where a DOM node is within the source document,
|
||||
* returning the parse5 location info for the node.
|
||||
*
|
||||
* @throws {Error} If the JSDOM was not created with `includeNodeLocations`
|
||||
*/
|
||||
nodeLocation(node: Node): ElementLocation | null;
|
||||
|
||||
/**
|
||||
* The built-in `vm` module of Node.js is what underpins JSDOM's script-running magic.
|
||||
* Some advanced use cases, like pre-compiling a script and then running it multiple
|
||||
* times, benefit from using the `vm` module directly with a jsdom-created `Window`.
|
||||
*
|
||||
* @throws {TypeError}
|
||||
* Note that this method will throw an exception if the `JSDOM` instance was created
|
||||
* without `runScripts` set, or if you are using JSDOM in a web browser.
|
||||
*/
|
||||
getInternalVMContext(): Context;
|
||||
|
||||
/**
|
||||
* The reconfigure method allows changing the `window.top` and url from the outside.
|
||||
*/
|
||||
reconfigure(settings: ReconfigureSettings): void;
|
||||
}
|
||||
|
||||
class ResourceLoader {
|
||||
fetch(url: string, options: FetchOptions): Promise<Buffer> | null;
|
||||
|
||||
constructor(obj?: ResourceLoaderConstructorOptions);
|
||||
}
|
||||
|
||||
class VirtualConsole extends EventEmitter {
|
||||
on<K extends keyof Console>(method: K, callback: Console[K]): this;
|
||||
on(event: "jsdomError", callback: (e: Error) => void): this;
|
||||
|
||||
sendTo(console: Console, options?: VirtualConsoleSendToOptions): this;
|
||||
}
|
||||
|
||||
type BinaryData = ArrayBufferLike | NodeJS.ArrayBufferView;
|
||||
interface BaseOptions {
|
||||
/**
|
||||
* referrer just affects the value read from document.referrer.
|
||||
* It defaults to no referrer (which reflects as the empty string).
|
||||
*/
|
||||
referrer?: string;
|
||||
|
||||
/**
|
||||
* userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
|
||||
*
|
||||
* @default
|
||||
* `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
|
||||
*/
|
||||
userAgent?: string;
|
||||
|
||||
/**
|
||||
* `includeNodeLocations` preserves the location info produced by the HTML parser,
|
||||
* allowing you to retrieve it with the nodeLocation() method (described below).
|
||||
*
|
||||
* It defaults to false to give the best performance,
|
||||
* and cannot be used with an XML content type since our XML parser does not support location info.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
includeNodeLocations?: boolean;
|
||||
runScripts?: "dangerously" | "outside-only";
|
||||
resources?: "usable" | ResourceLoader;
|
||||
virtualConsole?: VirtualConsole;
|
||||
cookieJar?: CookieJar;
|
||||
|
||||
/**
|
||||
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
||||
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
||||
*
|
||||
* When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
|
||||
* content.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
pretendToBeVisual?: boolean;
|
||||
beforeParse?(window: DOMWindow): void;
|
||||
}
|
||||
|
||||
interface FileOptions extends BaseOptions {
|
||||
/**
|
||||
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
||||
* and affects things like resolution of relative URLs within the document
|
||||
* and the same-origin restrictions and referrer used while fetching subresources.
|
||||
* It will default to a file URL corresponding to the given filename, instead of to "about:blank".
|
||||
*/
|
||||
url?: string;
|
||||
|
||||
/**
|
||||
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
||||
* Values that are not "text/html" or an XML mime type will throw. It will default to "application/xhtml+xml" if
|
||||
* the given filename ends in .xhtml or .xml; otherwise it will continue to default to "text/html".
|
||||
*/
|
||||
contentType?: string;
|
||||
}
|
||||
|
||||
interface ConstructorOptions extends BaseOptions {
|
||||
/**
|
||||
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
||||
* and affects things like resolution of relative URLs within the document
|
||||
* and the same-origin restrictions and referrer used while fetching subresources.
|
||||
* It defaults to "about:blank".
|
||||
*/
|
||||
url?: string;
|
||||
|
||||
/**
|
||||
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
||||
* Values that are not "text/html" or an XML mime type will throw. It defaults to "text/html".
|
||||
*/
|
||||
contentType?: string;
|
||||
|
||||
/**
|
||||
* The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
|
||||
* Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
|
||||
* to 5,000,000 code units per origin, as inspired by the HTML specification.
|
||||
*
|
||||
* @default 5_000_000
|
||||
*/
|
||||
storageQuota?: number;
|
||||
}
|
||||
|
||||
interface VirtualConsoleSendToOptions {
|
||||
omitJSDOMErrors: boolean;
|
||||
}
|
||||
|
||||
interface ReconfigureSettings {
|
||||
windowTop?: DOMWindow;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
interface FetchOptions {
|
||||
cookieJar?: CookieJar;
|
||||
referrer?: string;
|
||||
accept?: string;
|
||||
element?: HTMLScriptElement | HTMLLinkElement | HTMLIFrameElement | HTMLImageElement;
|
||||
}
|
||||
|
||||
interface ResourceLoaderConstructorOptions {
|
||||
strictSSL?: boolean;
|
||||
proxy?: string;
|
||||
userAgent?: string;
|
||||
}
|
||||
|
||||
interface DOMWindow extends Omit<Window, "top" | "self" | "window"> {
|
||||
[key: string]: any;
|
||||
|
||||
/* node_modules/jsdom/browser/Window.js */
|
||||
Window: typeof Window;
|
||||
readonly top: DOMWindow;
|
||||
readonly self: DOMWindow;
|
||||
readonly window: DOMWindow;
|
||||
|
||||
/* ECMAScript Globals */
|
||||
globalThis: DOMWindow;
|
||||
readonly ["Infinity"]: number;
|
||||
readonly ["NaN"]: number;
|
||||
readonly undefined: undefined;
|
||||
|
||||
eval(script: string): any;
|
||||
parseInt(s: string, radix?: number): number;
|
||||
parseFloat(string: string): number;
|
||||
isNaN(number: number): boolean;
|
||||
isFinite(number: number): boolean;
|
||||
decodeURI(encodedURI: string): string;
|
||||
decodeURIComponent(encodedURIComponent: string): string;
|
||||
encodeURI(uri: string): string;
|
||||
encodeURIComponent(uriComponent: string | number | boolean): string;
|
||||
escape(string: string): string;
|
||||
unescape(string: string): string;
|
||||
|
||||
Array: typeof Array;
|
||||
ArrayBuffer: typeof ArrayBuffer;
|
||||
Atomics: typeof Atomics;
|
||||
BigInt: typeof BigInt;
|
||||
BigInt64Array: typeof BigInt64Array;
|
||||
BigUint64Array: typeof BigUint64Array;
|
||||
Boolean: typeof Boolean;
|
||||
DataView: typeof DataView;
|
||||
Date: typeof Date;
|
||||
Error: typeof Error;
|
||||
EvalError: typeof EvalError;
|
||||
Float32Array: typeof Float32Array;
|
||||
Float64Array: typeof Float64Array;
|
||||
Function: typeof Function;
|
||||
Int16Array: typeof Int16Array;
|
||||
Int32Array: typeof Int32Array;
|
||||
Int8Array: typeof Int8Array;
|
||||
Intl: typeof Intl;
|
||||
JSON: typeof JSON;
|
||||
Map: typeof Map;
|
||||
Math: typeof Math;
|
||||
Number: typeof Number;
|
||||
Object: typeof Object;
|
||||
Promise: typeof Promise;
|
||||
Proxy: typeof Proxy;
|
||||
RangeError: typeof RangeError;
|
||||
ReferenceError: typeof ReferenceError;
|
||||
Reflect: typeof Reflect;
|
||||
RegExp: typeof RegExp;
|
||||
Set: typeof Set;
|
||||
SharedArrayBuffer: typeof SharedArrayBuffer;
|
||||
String: typeof String;
|
||||
Symbol: typeof Symbol;
|
||||
SyntaxError: typeof SyntaxError;
|
||||
TypeError: typeof TypeError;
|
||||
URIError: typeof URIError;
|
||||
Uint16Array: typeof Uint16Array;
|
||||
Uint32Array: typeof Uint32Array;
|
||||
Uint8Array: typeof Uint8Array;
|
||||
Uint8ClampedArray: typeof Uint8ClampedArray;
|
||||
WeakMap: typeof WeakMap;
|
||||
WeakSet: typeof WeakSet;
|
||||
WebAssembly: typeof WebAssembly;
|
||||
|
||||
/* node_modules/jsdom/living/interfaces.js */
|
||||
DOMException: typeof DOMException;
|
||||
|
||||
URL: typeof URL;
|
||||
URLSearchParams: typeof URLSearchParams;
|
||||
|
||||
EventTarget: typeof EventTarget;
|
||||
|
||||
NamedNodeMap: typeof NamedNodeMap;
|
||||
Node: typeof Node;
|
||||
Attr: typeof Attr;
|
||||
Element: typeof Element;
|
||||
DocumentFragment: typeof DocumentFragment;
|
||||
DOMImplementation: typeof DOMImplementation;
|
||||
Document: typeof Document;
|
||||
HTMLDocument: typeof HTMLDocument;
|
||||
XMLDocument: typeof XMLDocument;
|
||||
CharacterData: typeof CharacterData;
|
||||
Text: typeof Text;
|
||||
CDATASection: typeof CDATASection;
|
||||
ProcessingInstruction: typeof ProcessingInstruction;
|
||||
Comment: typeof Comment;
|
||||
DocumentType: typeof DocumentType;
|
||||
NodeList: typeof NodeList;
|
||||
HTMLCollection: typeof HTMLCollection;
|
||||
HTMLOptionsCollection: typeof HTMLOptionsCollection;
|
||||
DOMStringMap: typeof DOMStringMap;
|
||||
DOMTokenList: typeof DOMTokenList;
|
||||
|
||||
StyleSheetList: typeof StyleSheetList;
|
||||
|
||||
HTMLElement: typeof HTMLElement;
|
||||
HTMLHeadElement: typeof HTMLHeadElement;
|
||||
HTMLTitleElement: typeof HTMLTitleElement;
|
||||
HTMLBaseElement: typeof HTMLBaseElement;
|
||||
HTMLLinkElement: typeof HTMLLinkElement;
|
||||
HTMLMetaElement: typeof HTMLMetaElement;
|
||||
HTMLStyleElement: typeof HTMLStyleElement;
|
||||
HTMLBodyElement: typeof HTMLBodyElement;
|
||||
HTMLHeadingElement: typeof HTMLHeadingElement;
|
||||
HTMLParagraphElement: typeof HTMLParagraphElement;
|
||||
HTMLHRElement: typeof HTMLHRElement;
|
||||
HTMLPreElement: typeof HTMLPreElement;
|
||||
HTMLUListElement: typeof HTMLUListElement;
|
||||
HTMLOListElement: typeof HTMLOListElement;
|
||||
HTMLLIElement: typeof HTMLLIElement;
|
||||
HTMLMenuElement: typeof HTMLMenuElement;
|
||||
HTMLDListElement: typeof HTMLDListElement;
|
||||
HTMLDivElement: typeof HTMLDivElement;
|
||||
HTMLAnchorElement: typeof HTMLAnchorElement;
|
||||
HTMLAreaElement: typeof HTMLAreaElement;
|
||||
HTMLBRElement: typeof HTMLBRElement;
|
||||
HTMLButtonElement: typeof HTMLButtonElement;
|
||||
HTMLCanvasElement: typeof HTMLCanvasElement;
|
||||
HTMLDataElement: typeof HTMLDataElement;
|
||||
HTMLDataListElement: typeof HTMLDataListElement;
|
||||
HTMLDetailsElement: typeof HTMLDetailsElement;
|
||||
HTMLDialogElement: typeof HTMLDialogElement;
|
||||
HTMLDirectoryElement: typeof HTMLDirectoryElement;
|
||||
HTMLFieldSetElement: typeof HTMLFieldSetElement;
|
||||
HTMLFontElement: typeof HTMLFontElement;
|
||||
HTMLFormElement: typeof HTMLFormElement;
|
||||
HTMLHtmlElement: typeof HTMLHtmlElement;
|
||||
HTMLImageElement: typeof HTMLImageElement;
|
||||
HTMLInputElement: typeof HTMLInputElement;
|
||||
HTMLLabelElement: typeof HTMLLabelElement;
|
||||
HTMLLegendElement: typeof HTMLLegendElement;
|
||||
HTMLMapElement: typeof HTMLMapElement;
|
||||
HTMLMarqueeElement: typeof HTMLMarqueeElement;
|
||||
HTMLMediaElement: typeof HTMLMediaElement;
|
||||
HTMLMeterElement: typeof HTMLMeterElement;
|
||||
HTMLModElement: typeof HTMLModElement;
|
||||
HTMLOptGroupElement: typeof HTMLOptGroupElement;
|
||||
HTMLOptionElement: typeof HTMLOptionElement;
|
||||
HTMLOutputElement: typeof HTMLOutputElement;
|
||||
HTMLPictureElement: typeof HTMLPictureElement;
|
||||
HTMLProgressElement: typeof HTMLProgressElement;
|
||||
HTMLQuoteElement: typeof HTMLQuoteElement;
|
||||
HTMLScriptElement: typeof HTMLScriptElement;
|
||||
HTMLSelectElement: typeof HTMLSelectElement;
|
||||
HTMLSlotElement: typeof HTMLSlotElement;
|
||||
HTMLSourceElement: typeof HTMLSourceElement;
|
||||
HTMLSpanElement: typeof HTMLSpanElement;
|
||||
HTMLTableCaptionElement: typeof HTMLTableCaptionElement;
|
||||
HTMLTableCellElement: typeof HTMLTableCellElement;
|
||||
HTMLTableColElement: typeof HTMLTableColElement;
|
||||
HTMLTableElement: typeof HTMLTableElement;
|
||||
HTMLTimeElement: typeof HTMLTimeElement;
|
||||
HTMLTableRowElement: typeof HTMLTableRowElement;
|
||||
HTMLTableSectionElement: typeof HTMLTableSectionElement;
|
||||
HTMLTemplateElement: typeof HTMLTemplateElement;
|
||||
HTMLTextAreaElement: typeof HTMLTextAreaElement;
|
||||
HTMLUnknownElement: typeof HTMLUnknownElement;
|
||||
HTMLFrameElement: typeof HTMLFrameElement;
|
||||
HTMLFrameSetElement: typeof HTMLFrameSetElement;
|
||||
HTMLIFrameElement: typeof HTMLIFrameElement;
|
||||
HTMLEmbedElement: typeof HTMLEmbedElement;
|
||||
HTMLObjectElement: typeof HTMLObjectElement;
|
||||
HTMLParamElement: typeof HTMLParamElement;
|
||||
HTMLVideoElement: typeof HTMLVideoElement;
|
||||
HTMLAudioElement: typeof HTMLAudioElement;
|
||||
HTMLTrackElement: typeof HTMLTrackElement;
|
||||
|
||||
SVGElement: typeof SVGElement;
|
||||
SVGGraphicsElement: typeof SVGGraphicsElement;
|
||||
SVGSVGElement: typeof SVGSVGElement;
|
||||
SVGTitleElement: typeof SVGTitleElement;
|
||||
SVGAnimatedString: typeof SVGAnimatedString;
|
||||
SVGNumber: typeof SVGNumber;
|
||||
SVGStringList: typeof SVGStringList;
|
||||
|
||||
Event: typeof Event;
|
||||
CloseEvent: typeof CloseEvent;
|
||||
CustomEvent: typeof CustomEvent;
|
||||
MessageEvent: typeof MessageEvent;
|
||||
ErrorEvent: typeof ErrorEvent;
|
||||
HashChangeEvent: typeof HashChangeEvent;
|
||||
PopStateEvent: typeof PopStateEvent;
|
||||
StorageEvent: typeof StorageEvent;
|
||||
ProgressEvent: typeof ProgressEvent;
|
||||
PageTransitionEvent: typeof PageTransitionEvent;
|
||||
|
||||
UIEvent: typeof UIEvent;
|
||||
FocusEvent: typeof FocusEvent;
|
||||
MouseEvent: typeof MouseEvent;
|
||||
KeyboardEvent: typeof KeyboardEvent;
|
||||
TouchEvent: typeof TouchEvent;
|
||||
CompositionEvent: typeof CompositionEvent;
|
||||
WheelEvent: typeof WheelEvent;
|
||||
|
||||
BarProp: typeof BarProp;
|
||||
Location: typeof Location;
|
||||
History: typeof History;
|
||||
Screen: typeof Screen;
|
||||
Performance: typeof Performance;
|
||||
Navigator: typeof Navigator;
|
||||
|
||||
PluginArray: typeof PluginArray;
|
||||
MimeTypeArray: typeof MimeTypeArray;
|
||||
Plugin: typeof Plugin;
|
||||
MimeType: typeof MimeType;
|
||||
|
||||
FileReader: typeof FileReader;
|
||||
Blob: typeof Blob;
|
||||
File: typeof File;
|
||||
FileList: typeof FileList;
|
||||
ValidityState: typeof ValidityState;
|
||||
|
||||
DOMParser: typeof DOMParser;
|
||||
XMLSerializer: typeof XMLSerializer;
|
||||
|
||||
FormData: typeof FormData;
|
||||
XMLHttpRequestEventTarget: typeof XMLHttpRequestEventTarget;
|
||||
XMLHttpRequestUpload: typeof XMLHttpRequestUpload;
|
||||
XMLHttpRequest: typeof XMLHttpRequest;
|
||||
WebSocket: typeof WebSocket;
|
||||
|
||||
NodeFilter: typeof NodeFilter;
|
||||
NodeIterator: typeof NodeIterator;
|
||||
TreeWalker: typeof TreeWalker;
|
||||
|
||||
AbstractRange: typeof AbstractRange;
|
||||
Range: typeof Range;
|
||||
StaticRange: typeof StaticRange;
|
||||
Selection: typeof Selection;
|
||||
|
||||
Storage: typeof Storage;
|
||||
|
||||
CustomElementRegistry: typeof CustomElementRegistry;
|
||||
ShadowRoot: typeof ShadowRoot;
|
||||
|
||||
MutationObserver: typeof MutationObserver;
|
||||
MutationRecord: typeof MutationRecord;
|
||||
|
||||
Headers: typeof Headers;
|
||||
AbortController: typeof AbortController;
|
||||
AbortSignal: typeof AbortSignal;
|
||||
|
||||
/* node_modules/jsdom/level2/style.js */
|
||||
StyleSheet: typeof StyleSheet;
|
||||
MediaList: typeof MediaList;
|
||||
CSSStyleSheet: typeof CSSStyleSheet;
|
||||
CSSRule: typeof CSSRule;
|
||||
CSSStyleRule: typeof CSSStyleRule;
|
||||
CSSMediaRule: typeof CSSMediaRule;
|
||||
CSSImportRule: typeof CSSImportRule;
|
||||
CSSStyleDeclaration: typeof CSSStyleDeclaration;
|
||||
|
||||
/* node_modules/jsdom/level3/xpath.js */
|
||||
// XPathException: typeof XPathException;
|
||||
XPathExpression: typeof XPathExpression;
|
||||
XPathResult: typeof XPathResult;
|
||||
XPathEvaluator: typeof XPathEvaluator;
|
||||
}
|
||||
}
|
||||
2
types/jsdom/index.d.ts
vendored
2
types/jsdom/index.d.ts
vendored
@@ -8,7 +8,7 @@
|
||||
/// <reference path="ts3.5/index.d.ts"/>
|
||||
|
||||
// tslint:disable-next-line: no-declare-current-package no-single-declare-module
|
||||
declare module 'jsdom' {
|
||||
declare module "jsdom" {
|
||||
interface DOMWindow {
|
||||
InputEvent: typeof InputEvent;
|
||||
External: typeof External;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import './test/core';
|
||||
import jsdom = require('jsdom');
|
||||
import "./test/core";
|
||||
import jsdom = require("jsdom");
|
||||
|
||||
const dom = new jsdom.JSDOM();
|
||||
const domWindow = dom.window; // $ExpectType DOMWindow
|
||||
|
||||
domWindow.document.querySelector('slot'); // $ExpectType HTMLSlotElement | null
|
||||
domWindow.document.querySelector("slot"); // $ExpectType HTMLSlotElement | null
|
||||
domWindow.AbstractRange.prototype; // $ExpectType AbstractRange
|
||||
domWindow.StaticRange.prototype; // $ExpectType StaticRange
|
||||
domWindow.ShadowRoot.prototype; // $ExpectType ShadowRoot
|
||||
@@ -15,4 +15,6 @@ domWindow.BigInt64Array; // $ExpectType BigInt64ArrayConstructor
|
||||
domWindow.BigUint64Array; // $ExpectType BigUint64ArrayConstructor
|
||||
domWindow.SharedArrayBuffer; // $ExpectType SharedArrayBufferConstructor
|
||||
domWindow.WebAssembly; // $ExpectType typeof WebAssembly
|
||||
|
||||
domWindow.InputEvent.prototype; // $ExpectType InputEvent
|
||||
domWindow.external; // $ExpectType External
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
"types": "index",
|
||||
"typesVersions": {
|
||||
"<=3.5": {
|
||||
"*": [
|
||||
"ts3.5/*"
|
||||
]
|
||||
"*": ["ts3.5/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import {
|
||||
ResourceLoader,
|
||||
FetchOptions,
|
||||
ConstructorOptions,
|
||||
} from 'jsdom';
|
||||
import { CookieJar as ToughCookieJar, MemoryCookieStore } from 'tough-cookie';
|
||||
import { Script } from 'vm';
|
||||
} from "jsdom";
|
||||
import { CookieJar as ToughCookieJar, MemoryCookieStore } from "tough-cookie";
|
||||
import { Script } from "vm";
|
||||
|
||||
function test_basic_usage() {
|
||||
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
|
||||
console.log(dom.window.document.querySelector('p')!.textContent); // "Hello world"
|
||||
console.log(dom.window.document.querySelector("p")!.textContent); // "Hello world"
|
||||
|
||||
const { window } = new JSDOM(`...`);
|
||||
// or even
|
||||
@@ -35,7 +35,7 @@ function test_executing_scripts2() {
|
||||
`<body>
|
||||
<script>document.body.appendChild(document.createElement("hr"));</script>
|
||||
</body>`,
|
||||
{ runScripts: 'dangerously' },
|
||||
{ runScripts: "dangerously" },
|
||||
);
|
||||
|
||||
// The script will be executed and modify the DOM:
|
||||
@@ -43,7 +43,7 @@ function test_executing_scripts2() {
|
||||
}
|
||||
|
||||
function test_executing_scripts3() {
|
||||
const window = new JSDOM(``, { runScripts: 'outside-only' }).window;
|
||||
const window = new JSDOM(``, { runScripts: "outside-only" }).window;
|
||||
|
||||
window.eval(`document.body.innerHTML = "<p>Hello, world!</p>";`);
|
||||
window.document.body.children.length === 1;
|
||||
@@ -53,10 +53,10 @@ function test_virtualConsole() {
|
||||
const virtualConsole = new VirtualConsole();
|
||||
const dom = new JSDOM(``, { virtualConsole });
|
||||
|
||||
virtualConsole.on('error', () => {});
|
||||
virtualConsole.on('warn', () => {});
|
||||
virtualConsole.on('info', () => {});
|
||||
virtualConsole.on('dir', () => {});
|
||||
virtualConsole.on("error", () => {});
|
||||
virtualConsole.on("warn", () => {});
|
||||
virtualConsole.on("info", () => {});
|
||||
virtualConsole.on("dir", () => {});
|
||||
// ... etc. See https://console.spec.whatwg.org/#logging
|
||||
|
||||
virtualConsole.sendTo(console);
|
||||
@@ -80,21 +80,21 @@ function test_beforeParse() {
|
||||
}
|
||||
|
||||
function test_storageQuota() {
|
||||
new JSDOM('', { storageQuota: 1337 });
|
||||
new JSDOM("", { storageQuota: 1337 });
|
||||
}
|
||||
|
||||
function test_pretendToBeVisual() {
|
||||
new JSDOM('', { pretendToBeVisual: true });
|
||||
new JSDOM("", { pretendToBeVisual: true });
|
||||
}
|
||||
|
||||
function test_serialize() {
|
||||
const dom = new JSDOM(`<!DOCTYPE html>hello`);
|
||||
|
||||
dom.serialize() === '<!DOCTYPE html><html><head></head><body>hello</body></html>';
|
||||
dom.serialize() === "<!DOCTYPE html><html><head></head><body>hello</body></html>";
|
||||
|
||||
// Contrast with:
|
||||
// tslint:disable-next-line no-unnecessary-type-assertion
|
||||
dom.window.document.documentElement!.outerHTML === '<html><head></head><body>hello</body></html>';
|
||||
dom.window.document.documentElement!.outerHTML === "<html><head></head><body>hello</body></html>";
|
||||
}
|
||||
|
||||
function test_nodeLocation() {
|
||||
@@ -107,9 +107,9 @@ function test_nodeLocation() {
|
||||
|
||||
const document = dom.window.document;
|
||||
const bodyEl = document.body; // implicitly created
|
||||
const pEl = document.querySelector('p')!;
|
||||
const pEl = document.querySelector("p")!;
|
||||
const textNode = pEl.firstChild!;
|
||||
const imgEl = document.querySelector('img')!;
|
||||
const imgEl = document.querySelector("img")!;
|
||||
|
||||
console.log(dom.nodeLocation(bodyEl)); // null; it's not in the source
|
||||
console.log(dom.nodeLocation(pEl)); // { startOffset: 0, endOffset: 39, startTag: ..., endTag: ... }
|
||||
@@ -118,7 +118,7 @@ function test_nodeLocation() {
|
||||
}
|
||||
|
||||
function test_runVMScript() {
|
||||
const dom = new JSDOM(``, { runScripts: 'outside-only' });
|
||||
const dom = new JSDOM(``, { runScripts: "outside-only" });
|
||||
const script = new Script(`
|
||||
if (!this.ran) {
|
||||
this.ran = 0;
|
||||
@@ -139,30 +139,30 @@ function test_reconfigure(myFakeTopForTesting: DOMWindow) {
|
||||
const dom = new JSDOM();
|
||||
|
||||
dom.window.top === dom.window;
|
||||
dom.window.location.href === 'about:blank';
|
||||
dom.window.location.href === "about:blank";
|
||||
|
||||
dom.reconfigure({ windowTop: myFakeTopForTesting, url: 'https://example.com/' });
|
||||
dom.reconfigure({ windowTop: myFakeTopForTesting, url: "https://example.com/" });
|
||||
|
||||
dom.window.top === myFakeTopForTesting;
|
||||
dom.window.location.href === 'https://example.com/';
|
||||
dom.window.location.href === "https://example.com/";
|
||||
}
|
||||
|
||||
function test_fromURL() {
|
||||
const options: BaseOptions = {};
|
||||
|
||||
JSDOM.fromURL('https://example.com/', options).then(dom => {
|
||||
JSDOM.fromURL("https://example.com/", options).then(dom => {
|
||||
console.log(dom.serialize());
|
||||
});
|
||||
|
||||
function pretendToBeVisual() {
|
||||
JSDOM.fromURL('https://github.com', {
|
||||
JSDOM.fromURL("https://github.com", {
|
||||
pretendToBeVisual: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function test_fromFile(options: FileOptions) {
|
||||
JSDOM.fromFile('stuff.html', options).then(dom => {
|
||||
JSDOM.fromFile("stuff.html", options).then(dom => {
|
||||
console.log(dom.serialize());
|
||||
});
|
||||
}
|
||||
@@ -171,7 +171,7 @@ function test_fragment() {
|
||||
const frag = JSDOM.fragment(`<p>Hello</p><p><strong>Hi!</strong>`);
|
||||
|
||||
frag.childNodes.length === 2;
|
||||
frag.querySelector('strong')!.textContent = 'Why hello there!';
|
||||
frag.querySelector("strong")!.textContent = "Why hello there!";
|
||||
// etc.
|
||||
}
|
||||
|
||||
@@ -199,5 +199,5 @@ function test_custom_resource_loader() {
|
||||
return super.fetch(url, options);
|
||||
}
|
||||
}
|
||||
new JSDOM('', { resources: new CustomResourceLoader() });
|
||||
new JSDOM("", { resources: new CustomResourceLoader() });
|
||||
}
|
||||
|
||||
454
types/jsdom/ts3.5/index.d.ts
vendored
454
types/jsdom/ts3.5/index.d.ts
vendored
@@ -1,453 +1,5 @@
|
||||
// tslint:disable-next-line: no-bad-reference
|
||||
/// <reference types="node" />
|
||||
/// <reference path="../base.d.ts"/>
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
import { ElementLocation } from 'parse5';
|
||||
import { Context } from 'vm';
|
||||
import * as tough from 'tough-cookie';
|
||||
|
||||
declare module 'jsdom' {
|
||||
const toughCookie: typeof tough;
|
||||
class CookieJar extends tough.CookieJar {}
|
||||
|
||||
class JSDOM {
|
||||
constructor(html?: string | Buffer | BinaryData, options?: ConstructorOptions);
|
||||
|
||||
static fromURL(url: string, options?: BaseOptions): Promise<JSDOM>;
|
||||
static fromFile(url: string, options?: FileOptions): Promise<JSDOM>;
|
||||
static fragment(html: string): DocumentFragment;
|
||||
|
||||
readonly window: DOMWindow;
|
||||
readonly virtualConsole: VirtualConsole;
|
||||
readonly cookieJar: CookieJar;
|
||||
|
||||
/**
|
||||
* The serialize() method will return the HTML serialization of the document, including the doctype.
|
||||
*/
|
||||
serialize(): string;
|
||||
|
||||
/**
|
||||
* The nodeLocation() method will find where a DOM node is within the source document,
|
||||
* returning the parse5 location info for the node.
|
||||
*
|
||||
* @throws {Error} If the JSDOM was not created with `includeNodeLocations`
|
||||
*/
|
||||
nodeLocation(node: Node): ElementLocation | null;
|
||||
|
||||
/**
|
||||
* The built-in `vm` module of Node.js is what underpins JSDOM's script-running magic.
|
||||
* Some advanced use cases, like pre-compiling a script and then running it multiple
|
||||
* times, benefit from using the `vm` module directly with a jsdom-created `Window`.
|
||||
*
|
||||
* @throws {TypeError}
|
||||
* Note that this method will throw an exception if the `JSDOM` instance was created
|
||||
* without `runScripts` set, or if you are using JSDOM in a web browser.
|
||||
*/
|
||||
getInternalVMContext(): Context;
|
||||
|
||||
/**
|
||||
* The reconfigure method allows changing the `window.top` and url from the outside.
|
||||
*/
|
||||
reconfigure(settings: ReconfigureSettings): void;
|
||||
}
|
||||
|
||||
class ResourceLoader {
|
||||
fetch(url: string, options: FetchOptions): Promise<Buffer> | null;
|
||||
|
||||
constructor(obj?: ResourceLoaderConstructorOptions);
|
||||
}
|
||||
|
||||
class VirtualConsole extends EventEmitter {
|
||||
on<K extends keyof Console>(method: K, callback: Console[K]): this;
|
||||
on(event: 'jsdomError', callback: (e: Error) => void): this;
|
||||
|
||||
sendTo(console: Console, options?: VirtualConsoleSendToOptions): this;
|
||||
}
|
||||
|
||||
type BinaryData =
|
||||
| ArrayBuffer
|
||||
| DataView
|
||||
| Int8Array
|
||||
| Uint8Array
|
||||
| Uint8ClampedArray
|
||||
| Int16Array
|
||||
| Uint16Array
|
||||
| Int32Array
|
||||
| Uint32Array
|
||||
| Float32Array
|
||||
| Float64Array;
|
||||
|
||||
interface BaseOptions {
|
||||
/**
|
||||
* referrer just affects the value read from document.referrer.
|
||||
* It defaults to no referrer (which reflects as the empty string).
|
||||
*/
|
||||
referrer?: string;
|
||||
|
||||
/**
|
||||
* userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
|
||||
*
|
||||
* @default
|
||||
* `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
|
||||
*/
|
||||
userAgent?: string;
|
||||
|
||||
/**
|
||||
* `includeNodeLocations` preserves the location info produced by the HTML parser,
|
||||
* allowing you to retrieve it with the nodeLocation() method (described below).
|
||||
*
|
||||
* It defaults to false to give the best performance,
|
||||
* and cannot be used with an XML content type since our XML parser does not support location info.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
includeNodeLocations?: boolean;
|
||||
runScripts?: 'dangerously' | 'outside-only';
|
||||
resources?: 'usable' | ResourceLoader;
|
||||
virtualConsole?: VirtualConsole;
|
||||
cookieJar?: CookieJar;
|
||||
|
||||
/**
|
||||
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
||||
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
||||
*
|
||||
* When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
|
||||
* content.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
pretendToBeVisual?: boolean;
|
||||
beforeParse?(window: DOMWindow): void;
|
||||
}
|
||||
|
||||
interface FileOptions extends BaseOptions {
|
||||
/**
|
||||
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
||||
* and affects things like resolution of relative URLs within the document
|
||||
* and the same-origin restrictions and referrer used while fetching subresources.
|
||||
* It will default to a file URL corresponding to the given filename, instead of to "about:blank".
|
||||
*/
|
||||
url?: string;
|
||||
|
||||
/**
|
||||
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
||||
* Values that are not "text/html" or an XML mime type will throw. It will default to "application/xhtml+xml" if
|
||||
* the given filename ends in .xhtml or .xml; otherwise it will continue to default to "text/html".
|
||||
*/
|
||||
contentType?: string;
|
||||
}
|
||||
|
||||
interface ConstructorOptions extends BaseOptions {
|
||||
/**
|
||||
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
||||
* and affects things like resolution of relative URLs within the document
|
||||
* and the same-origin restrictions and referrer used while fetching subresources.
|
||||
* It defaults to "about:blank".
|
||||
*/
|
||||
url?: string;
|
||||
|
||||
/**
|
||||
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
||||
* Values that are not "text/html" or an XML mime type will throw. It defaults to "text/html".
|
||||
*/
|
||||
contentType?: string;
|
||||
|
||||
/**
|
||||
* The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
|
||||
* Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
|
||||
* to 5,000,000 code units per origin, as inspired by the HTML specification.
|
||||
*
|
||||
* @default 5_000_000
|
||||
*/
|
||||
storageQuota?: number;
|
||||
}
|
||||
|
||||
interface VirtualConsoleSendToOptions {
|
||||
omitJSDOMErrors: boolean;
|
||||
}
|
||||
|
||||
interface ReconfigureSettings {
|
||||
windowTop?: DOMWindow;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
interface FetchOptions {
|
||||
cookieJar?: CookieJar;
|
||||
referrer?: string;
|
||||
accept?: string;
|
||||
element?: HTMLScriptElement | HTMLLinkElement | HTMLIFrameElement | HTMLImageElement;
|
||||
}
|
||||
|
||||
interface ResourceLoaderConstructorOptions {
|
||||
strictSSL?: boolean;
|
||||
proxy?: string;
|
||||
userAgent?: string;
|
||||
}
|
||||
|
||||
interface DOMWindow extends Pick<Window, Exclude<keyof Window, 'top' | 'self' | 'window'>> {
|
||||
[key: string]: any;
|
||||
|
||||
/* node_modules/jsdom/browser/Window.js */
|
||||
Window: typeof Window;
|
||||
readonly top: DOMWindow;
|
||||
readonly self: DOMWindow;
|
||||
readonly window: DOMWindow;
|
||||
|
||||
/* ECMAScript Globals */
|
||||
globalThis: DOMWindow;
|
||||
readonly ['Infinity']: number;
|
||||
readonly ['NaN']: number;
|
||||
readonly undefined: undefined;
|
||||
|
||||
eval(script: string): any;
|
||||
parseInt(s: string, radix?: number): number;
|
||||
parseFloat(string: string): number;
|
||||
isNaN(number: number): boolean;
|
||||
isFinite(number: number): boolean;
|
||||
decodeURI(encodedURI: string): string;
|
||||
decodeURIComponent(encodedURIComponent: string): string;
|
||||
encodeURI(uri: string): string;
|
||||
encodeURIComponent(uriComponent: string | number | boolean): string;
|
||||
escape(string: string): string;
|
||||
unescape(string: string): string;
|
||||
|
||||
Array: typeof Array;
|
||||
ArrayBuffer: typeof ArrayBuffer;
|
||||
Boolean: typeof Boolean;
|
||||
DataView: typeof DataView;
|
||||
Date: typeof Date;
|
||||
Error: typeof Error;
|
||||
EvalError: typeof EvalError;
|
||||
Float32Array: typeof Float32Array;
|
||||
Float64Array: typeof Float64Array;
|
||||
Function: typeof Function;
|
||||
Int16Array: typeof Int16Array;
|
||||
Int32Array: typeof Int32Array;
|
||||
Int8Array: typeof Int8Array;
|
||||
Intl: typeof Intl;
|
||||
JSON: typeof JSON;
|
||||
Map: typeof Map;
|
||||
Math: typeof Math;
|
||||
Number: typeof Number;
|
||||
Object: typeof Object;
|
||||
Promise: typeof Promise;
|
||||
Proxy: typeof Proxy;
|
||||
RangeError: typeof RangeError;
|
||||
ReferenceError: typeof ReferenceError;
|
||||
Reflect: typeof Reflect;
|
||||
RegExp: typeof RegExp;
|
||||
Set: typeof Set;
|
||||
String: typeof String;
|
||||
Symbol: typeof Symbol;
|
||||
SyntaxError: typeof SyntaxError;
|
||||
TypeError: typeof TypeError;
|
||||
URIError: typeof URIError;
|
||||
Uint16Array: typeof Uint16Array;
|
||||
Uint32Array: typeof Uint32Array;
|
||||
Uint8Array: typeof Uint8Array;
|
||||
Uint8ClampedArray: typeof Uint8ClampedArray;
|
||||
WeakMap: typeof WeakMap;
|
||||
WeakSet: typeof WeakSet;
|
||||
|
||||
/* node_modules/jsdom/living/interfaces.js */
|
||||
DOMException: typeof DOMException;
|
||||
|
||||
URL: typeof URL;
|
||||
URLSearchParams: typeof URLSearchParams;
|
||||
|
||||
EventTarget: typeof EventTarget;
|
||||
|
||||
NamedNodeMap: typeof NamedNodeMap;
|
||||
Node: typeof Node;
|
||||
Attr: typeof Attr;
|
||||
Element: typeof Element;
|
||||
DocumentFragment: typeof DocumentFragment;
|
||||
Document: typeof Document;
|
||||
XMLDocument: typeof XMLDocument;
|
||||
CharacterData: typeof CharacterData;
|
||||
Text: typeof Text;
|
||||
CDATASection: typeof CDATASection;
|
||||
ProcessingInstruction: typeof ProcessingInstruction;
|
||||
Comment: typeof Comment;
|
||||
DocumentType: typeof DocumentType;
|
||||
DOMImplementation: typeof DOMImplementation;
|
||||
NodeList: typeof NodeList;
|
||||
HTMLCollection: typeof HTMLCollection;
|
||||
HTMLOptionsCollection: typeof HTMLOptionsCollection;
|
||||
DOMStringMap: typeof DOMStringMap;
|
||||
DOMTokenList: typeof DOMTokenList;
|
||||
CustomElementRegistry: typeof CustomElementRegistry;
|
||||
|
||||
HTMLElement: typeof HTMLElement;
|
||||
HTMLHeadElement: typeof HTMLHeadElement;
|
||||
HTMLTitleElement: typeof HTMLTitleElement;
|
||||
HTMLBaseElement: typeof HTMLBaseElement;
|
||||
HTMLLinkElement: typeof HTMLLinkElement;
|
||||
HTMLMetaElement: typeof HTMLMetaElement;
|
||||
HTMLStyleElement: typeof HTMLStyleElement;
|
||||
HTMLBodyElement: typeof HTMLBodyElement;
|
||||
HTMLHeadingElement: typeof HTMLHeadingElement;
|
||||
HTMLParagraphElement: typeof HTMLParagraphElement;
|
||||
HTMLHRElement: typeof HTMLHRElement;
|
||||
HTMLPreElement: typeof HTMLPreElement;
|
||||
HTMLUListElement: typeof HTMLUListElement;
|
||||
HTMLOListElement: typeof HTMLOListElement;
|
||||
HTMLLIElement: typeof HTMLLIElement;
|
||||
HTMLMenuElement: typeof HTMLMenuElement;
|
||||
HTMLDListElement: typeof HTMLDListElement;
|
||||
HTMLDivElement: typeof HTMLDivElement;
|
||||
HTMLAnchorElement: typeof HTMLAnchorElement;
|
||||
HTMLAreaElement: typeof HTMLAreaElement;
|
||||
HTMLBRElement: typeof HTMLBRElement;
|
||||
HTMLButtonElement: typeof HTMLButtonElement;
|
||||
HTMLCanvasElement: typeof HTMLCanvasElement;
|
||||
HTMLDataElement: typeof HTMLDataElement;
|
||||
HTMLDataListElement: typeof HTMLDataListElement;
|
||||
HTMLDetailsElement: typeof HTMLDetailsElement;
|
||||
HTMLDialogElement: typeof HTMLDialogElement;
|
||||
HTMLDirectoryElement: typeof HTMLDirectoryElement;
|
||||
HTMLFieldSetElement: typeof HTMLFieldSetElement;
|
||||
HTMLFontElement: typeof HTMLFontElement;
|
||||
HTMLFormElement: typeof HTMLFormElement;
|
||||
HTMLHtmlElement: typeof HTMLHtmlElement;
|
||||
HTMLImageElement: typeof HTMLImageElement;
|
||||
HTMLInputElement: typeof HTMLInputElement;
|
||||
HTMLLabelElement: typeof HTMLLabelElement;
|
||||
HTMLLegendElement: typeof HTMLLegendElement;
|
||||
HTMLMapElement: typeof HTMLMapElement;
|
||||
HTMLMarqueeElement: typeof HTMLMarqueeElement;
|
||||
HTMLMediaElement: typeof HTMLMediaElement;
|
||||
HTMLMeterElement: typeof HTMLMeterElement;
|
||||
HTMLModElement: typeof HTMLModElement;
|
||||
HTMLOptGroupElement: typeof HTMLOptGroupElement;
|
||||
HTMLOptionElement: typeof HTMLOptionElement;
|
||||
HTMLOutputElement: typeof HTMLOutputElement;
|
||||
HTMLPictureElement: typeof HTMLPictureElement;
|
||||
HTMLProgressElement: typeof HTMLProgressElement;
|
||||
HTMLQuoteElement: typeof HTMLQuoteElement;
|
||||
HTMLScriptElement: typeof HTMLScriptElement;
|
||||
HTMLSelectElement: typeof HTMLSelectElement;
|
||||
HTMLSlotElement: typeof HTMLSlotElement;
|
||||
HTMLSourceElement: typeof HTMLSourceElement;
|
||||
HTMLSpanElement: typeof HTMLSpanElement;
|
||||
HTMLTableCaptionElement: typeof HTMLTableCaptionElement;
|
||||
HTMLTableCellElement: typeof HTMLTableCellElement;
|
||||
HTMLTableColElement: typeof HTMLTableColElement;
|
||||
HTMLTableElement: typeof HTMLTableElement;
|
||||
HTMLTimeElement: typeof HTMLTimeElement;
|
||||
HTMLTableRowElement: typeof HTMLTableRowElement;
|
||||
HTMLTableSectionElement: typeof HTMLTableSectionElement;
|
||||
HTMLTemplateElement: typeof HTMLTemplateElement;
|
||||
HTMLTextAreaElement: typeof HTMLTextAreaElement;
|
||||
HTMLUnknownElement: typeof HTMLUnknownElement;
|
||||
HTMLFrameElement: typeof HTMLFrameElement;
|
||||
HTMLFrameSetElement: typeof HTMLFrameSetElement;
|
||||
HTMLIFrameElement: typeof HTMLIFrameElement;
|
||||
HTMLEmbedElement: typeof HTMLEmbedElement;
|
||||
HTMLObjectElement: typeof HTMLObjectElement;
|
||||
HTMLParamElement: typeof HTMLParamElement;
|
||||
HTMLVideoElement: typeof HTMLVideoElement;
|
||||
HTMLAudioElement: typeof HTMLAudioElement;
|
||||
HTMLTrackElement: typeof HTMLTrackElement;
|
||||
|
||||
SVGElement: typeof SVGElement;
|
||||
SVGGraphicsElement: typeof SVGGraphicsElement;
|
||||
SVGSVGElement: typeof SVGSVGElement;
|
||||
SVGTitleElement: typeof SVGTitleElement;
|
||||
SVGAnimatedString: typeof SVGAnimatedString;
|
||||
SVGNumber: typeof SVGNumber;
|
||||
SVGStringList: typeof SVGStringList;
|
||||
|
||||
Event: typeof Event;
|
||||
CloseEvent: typeof CloseEvent;
|
||||
CustomEvent: typeof CustomEvent;
|
||||
MessageEvent: typeof MessageEvent;
|
||||
ErrorEvent: typeof ErrorEvent;
|
||||
HashChangeEvent: typeof HashChangeEvent;
|
||||
PopStateEvent: typeof PopStateEvent;
|
||||
StorageEvent: typeof StorageEvent;
|
||||
ProgressEvent: typeof ProgressEvent;
|
||||
PageTransitionEvent: typeof PageTransitionEvent;
|
||||
|
||||
UIEvent: typeof UIEvent;
|
||||
FocusEvent: typeof FocusEvent;
|
||||
MouseEvent: typeof MouseEvent;
|
||||
KeyboardEvent: typeof KeyboardEvent;
|
||||
TouchEvent: typeof TouchEvent;
|
||||
CompositionEvent: typeof CompositionEvent;
|
||||
WheelEvent: typeof WheelEvent;
|
||||
|
||||
BarProp: typeof BarProp;
|
||||
Location: typeof Location;
|
||||
History: typeof History;
|
||||
Screen: typeof Screen;
|
||||
Performance: typeof Performance;
|
||||
Navigator: typeof Navigator;
|
||||
|
||||
PluginArray: typeof PluginArray;
|
||||
MimeTypeArray: typeof MimeTypeArray;
|
||||
Plugin: typeof Plugin;
|
||||
MimeType: typeof MimeType;
|
||||
|
||||
FileReader: typeof FileReader;
|
||||
Blob: typeof Blob;
|
||||
File: typeof File;
|
||||
FileList: typeof FileList;
|
||||
ValidityState: typeof ValidityState;
|
||||
|
||||
DOMParser: typeof DOMParser;
|
||||
XMLSerializer: typeof XMLSerializer;
|
||||
|
||||
FormData: typeof FormData;
|
||||
XMLHttpRequestEventTarget: typeof XMLHttpRequestEventTarget;
|
||||
XMLHttpRequestUpload: typeof XMLHttpRequestUpload;
|
||||
XMLHttpRequest: typeof XMLHttpRequest;
|
||||
WebSocket: typeof WebSocket;
|
||||
|
||||
NodeIterator: typeof NodeIterator;
|
||||
TreeWalker: typeof TreeWalker;
|
||||
|
||||
Range: typeof Range;
|
||||
AbstractRange: typeof AbstractRange;
|
||||
StaticRange: typeof StaticRange;
|
||||
Selection: typeof Selection;
|
||||
|
||||
Storage: typeof Storage;
|
||||
|
||||
MutationObserver: typeof MutationObserver;
|
||||
MutationRecord: typeof MutationRecord;
|
||||
|
||||
Headers: typeof Headers;
|
||||
AbortController: typeof AbortController;
|
||||
AbortSignal: typeof AbortSignal;
|
||||
|
||||
/* node_modules/jsdom/living/node-filter.js */
|
||||
NodeFilter: typeof NodeFilter;
|
||||
|
||||
/* node_modules/jsdom/level2/style.js */
|
||||
StyleSheet: typeof StyleSheet;
|
||||
MediaList: typeof MediaList;
|
||||
CSSStyleSheet: typeof CSSStyleSheet;
|
||||
CSSRule: typeof CSSRule;
|
||||
CSSStyleRule: typeof CSSStyleRule;
|
||||
CSSMediaRule: typeof CSSMediaRule;
|
||||
CSSImportRule: typeof CSSImportRule;
|
||||
CSSStyleDeclaration: typeof CSSStyleDeclaration;
|
||||
StyleSheetList: typeof StyleSheetList;
|
||||
|
||||
/* node_modules/jsdom/level3/xpath.js */
|
||||
// XPathException: typeof XPathException;
|
||||
XPathExpression: typeof XPathExpression;
|
||||
XPathResult: typeof XPathResult;
|
||||
XPathEvaluator: typeof XPathEvaluator;
|
||||
|
||||
ShadowRoot: typeof ShadowRoot;
|
||||
|
||||
Atomics: typeof Atomics;
|
||||
BigInt: typeof BigInt;
|
||||
BigInt64Array: typeof BigInt64Array;
|
||||
BigUint64Array: typeof BigUint64Array;
|
||||
SharedArrayBuffer: typeof SharedArrayBuffer;
|
||||
WebAssembly: typeof WebAssembly;
|
||||
}
|
||||
}
|
||||
// tslint:disable-next-line: no-single-declare-module
|
||||
declare module "jsdom" {}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import '../test/core';
|
||||
import jsdom = require('jsdom');
|
||||
import "../test/core";
|
||||
import jsdom = require("jsdom");
|
||||
|
||||
const dom = new jsdom.JSDOM();
|
||||
const domWindow = dom.window; // $ExpectType DOMWindow
|
||||
|
||||
domWindow.document.querySelector('slot'); // $ExpectType HTMLSlotElement | null
|
||||
domWindow.document.querySelector("slot"); // $ExpectType HTMLSlotElement | null
|
||||
domWindow.AbstractRange.prototype; // $ExpectType AbstractRange
|
||||
domWindow.StaticRange.prototype; // $ExpectType StaticRange
|
||||
domWindow.ShadowRoot.prototype; // $ExpectType ShadowRoot
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es2020", "dom"],
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es2015", "dom"],
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
Reference in New Issue
Block a user