mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
jsdom: ResourceLoader#fetch may return null (#43669)
According to the jsdom documentation, ResourceLoader#fetch may return null to indicate that the resource was intentionally not loaded.
This commit is contained in:
Vendored
+1
-1
@@ -62,7 +62,7 @@ declare module 'jsdom' {
|
||||
}
|
||||
|
||||
class ResourceLoader {
|
||||
fetch(url: string, options: FetchOptions): Promise<Buffer>;
|
||||
fetch(url: string, options: FetchOptions): Promise<Buffer> | null;
|
||||
|
||||
constructor(obj?: ResourceLoaderConstructorOptions);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user