diff --git a/src/HTMLImports.js b/src/HTMLImports.js
index 42c2b93..ad4d459 100644
--- a/src/HTMLImports.js
+++ b/src/HTMLImports.js
@@ -441,6 +441,19 @@ xhr = xhr || {
var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);
+// expose _currentScript
+Object.defineProperty(document, '_currentScript', {
+ get: function() {
+ return HTMLImports.currentScript || document.currentScript;
+ },
+ set: function(script) {
+ HTMLImports.currentScript = script;
+ },
+ writeable: true,
+ configurable: true
+});
+
+
// exports
scope.path = path;
diff --git a/src/Parser.js b/src/Parser.js
index b58ba2a..0d41be1 100644
--- a/src/Parser.js
+++ b/src/Parser.js
@@ -83,7 +83,9 @@ var importParser = {
// source map hint
code += "\n//# sourceURL=" + moniker + "\n";
// evaluate the code
+ scope.currentScript = scriptElt;
eval.call(window, code);
+ scope.currentScript = null;
}
}
}