currentExecutingScript
currentExecutingScript copied to clipboard
Get the currently executing script, regardless of its source/trigger/synchronicity. Similar to HTML5's `document.currentScript` but arguably much more useful!
Implement an experimental function called `.far()` for finding the farthest (most shallow) `script` element for the current execution call stack.
``` json { "license": "MIT" } ```
StackTrace.js has extracted its internal stack parser as ["error-stack-parser"](https://github.com/stacktracejs/error-stack-parser), with 1 dependency on ["stackframe"](https://github.com/stacktracejs/stackframe) (a simple internal data model to represent frames in the call stack). Make both `devDependencies`, then...
**Critical Piece:** Being able to get the function reference to the calling function, e.g. via `_nearestExecutingScript.caller`/`arguments.callee.caller`/`arguments.caller`. Seems like `"use strict"` (JS strict mode) usage will make this next to impossible/useless....
Per @ollym's request on JamesMGreene/document.currentScript#9: > It would be helpful if you could list the techniques you're using for script detection in english. The source code structure makes it difficult...
Implement an experimental function called `.origin()` for finding the originating `script` _or attribute node_ (e.g. `onclick`) for the current execution call stack.
e.g. for Chrome: https://code.google.com/p/v8-wiki/wiki/JavaScriptStackTraceApi#Appendix:_Stack_trace_format There are some special cases, e.g. location when a function was created via `eval`, is native, cannot be located, etc.