diff --git a/types/jsdom/index.d.ts b/types/jsdom/index.d.ts index 78d4004986..18a24addfe 100644 --- a/types/jsdom/index.d.ts +++ b/types/jsdom/index.d.ts @@ -62,7 +62,7 @@ declare module 'jsdom' { } class ResourceLoader { - fetch(url: string, options: FetchOptions): Promise; + fetch(url: string, options: FetchOptions): Promise | null; constructor(obj?: ResourceLoaderConstructorOptions); } diff --git a/types/jsdom/jsdom-tests.ts b/types/jsdom/jsdom-tests.ts index f9ef16b9ec..e5d4955364 100644 --- a/types/jsdom/jsdom-tests.ts +++ b/types/jsdom/jsdom-tests.ts @@ -190,6 +190,11 @@ function test_custom_resource_loader() { fetch(url: string, options: FetchOptions) { if (options.element) { console.log(`Element ${options.element.localName} is requesting the url ${url}`); + + if (options.element.localName === "iframe") { + console.log("Ignoring resource requested by iframe element"); + return null; + } } return super.fetch(url, options);