| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,6 @@ const { | |||
| 8 | 8 | ArrayIsArray, | |
| 9 | 9 | ArrayPrototypeJoin, | |
| 10 | 10 | ArrayPrototypePush, | |
| 11 | - FunctionPrototypeBind, | ||
| 12 | 11 | FunctionPrototypeCall, | |
| 13 | 12 | ObjectAssign, | |
| 14 | 13 | ObjectCreate, | |
@@ -306,16 +305,14 @@ class ESMLoader { | |||
| 306 | 305 | 'DeprecationWarning', | |
| 307 | 306 | ); | |
| 308 | 307 | ||
| 309 | - // Use .bind() to avoid giving access to the Loader instance when called. | ||
| 310 | 308 | if (globalPreload) { | |
| 311 | - acceptedHooks.globalPreloader = | ||
| 312 | - FunctionPrototypeBind(globalPreload, null); | ||
| 309 | + acceptedHooks.globalPreloader = globalPreload; | ||
| 313 | 310 | } | |
| 314 | 311 | if (resolve) { | |
| 315 | - acceptedHooks.resolver = FunctionPrototypeBind(resolve, null); | ||
| 312 | + acceptedHooks.resolver = resolve; | ||
| 316 | 313 | } | |
| 317 | 314 | if (load) { | |
| 318 | - acceptedHooks.loader = FunctionPrototypeBind(load, null); | ||
| 315 | + acceptedHooks.loader = load; | ||
| 319 | 316 | } | |
| 320 | 317 | ||
| 321 | 318 | return acceptedHooks; | |
@@ -346,7 +343,7 @@ class ESMLoader { | |||
| 346 | 343 | ArrayPrototypePush( | |
| 347 | 344 | this.#globalPreloaders, | |
| 348 | 345 | { | |
| 349 | - fn: FunctionPrototypeBind(globalPreloader), // [1] | ||
| 346 | + fn: globalPreloader, | ||
| 350 | 347 | url, | |
| 351 | 348 | }, | |
| 352 | 349 | ); | |
@@ -355,7 +352,7 @@ class ESMLoader { | |||
| 355 | 352 | ArrayPrototypePush( | |
| 356 | 353 | this.#resolvers, | |
| 357 | 354 | { | |
| 358 | - fn: FunctionPrototypeBind(resolver), // [1] | ||
| 355 | + fn: resolver, | ||
| 359 | 356 | url, | |
| 360 | 357 | }, | |
| 361 | 358 | ); | |
@@ -364,15 +361,13 @@ class ESMLoader { | |||
| 364 | 361 | ArrayPrototypePush( | |
| 365 | 362 | this.#loaders, | |
| 366 | 363 | { | |
| 367 | - fn: FunctionPrototypeBind(loader), // [1] | ||
| 364 | + fn: loader, | ||
| 368 | 365 | url, | |
| 369 | 366 | }, | |
| 370 | 367 | ); | |
| 371 | 368 | } | |
| 372 | 369 | } | |
| 373 | 370 | ||
| 374 | - // [1] ensure hook function is not bound to ESMLoader instance | ||
| 375 | - | ||
| 376 | 371 | this.preload(); | |
| 377 | 372 | } | |
| 378 | 373 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + export function resolve(url, _, next) { | ||
| 2 | + if (this != null) throw new Error('hook function must not be bound to ESMLoader instance'); | ||
| 3 | + return next(url); | ||
| 4 | + } | ||
| 5 | + | ||
| 6 | + export function load(url, _, next) { | ||
| 7 | + if (this != null) throw new Error('hook function must not be bound to ESMLoader instance'); | ||
| 8 | + return next(url); | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + export function globalPreload() { | ||
| 12 | + if (this != null) throw new Error('hook function must not be bound to ESMLoader instance'); | ||
| 13 | + return ""; | ||
| 14 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + // Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-this-value-inside-hook-functions.mjs | ||
| 2 | + import '../common/index.mjs'; | ||
| 3 | + | ||
| 4 | + // Actual test is inside the loader module. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments