Closed aknuds1 closed 7 years ago
Should we also aim to provided updated documentation around why the caller
argument is required?
@joshgillies Thanks for the suggestion, I've edited the README.
I don't think it should be obligatory. If it was, it would mean everyone using the library would have to agree on unique global names for their elements. I think it's ok to specify your own name, if you really need/want to but it's going to conflict eventually in more complex environments.
Ultimately it should be a build step in production that specifies a for sure unique name and then fall back on Function.caller
or another method of your choosing for dev mode. I'm open to other ideas on uniquely identifying a portion of code too or a changing the API so it's not needed somehow.
The technique for deducing the
caller
argument toonload
is unsound, asFunction.caller
is disallowed in strict mode and apparently generally considered a bad idea.This patch makes the caller argument obligatory. However: How should we test that
caller
is passed? Throw an exception?Also, if anyone has suggestions for some safe way of auto-generating the
caller
parameter rather than resorting toFunction.caller
, that would be great.Fixes #15