Closed unscriptable closed 10 years ago
The way it is spec'd right now, hooks override methods in the new Loader instance. So these two are equivalent:
var loader = new Loader({ fetch: fn });
var loader2 = new Loader();
loader2.fetch = fn;
This means that it'll default to Loader.prototype.fetch
(which throws). From 26.3.1.1.9:
If hook is not undefined, If isCallable(hook) is false, throw a TypeError exception. Let result be CreatePropertyOrThrow(loader, name, hook).
See http://people.mozilla.org/~jorendorff/es6-draft.html#sec-%loader%.
So yes, it throws.
The environment default behavior is baked into the System
instance of Loader
, not into the class Loader
.
thanks guys!
If a dev constructs a new loader with no hooks (e.g.
new Loader({/* no hooks */});
), will the loader be functional? Does it take-on some default behavior based on the environment? Or does it throw an exception if you try toimport
using it?