This does not work on IE 11
KirillBorunov opened this issue · 8 comments
As others currentScript polyfills, this one also relies on the script.readyState and not working on IE 11.
Its been a very long time since I touched this, but it looks I supported IE11 by grabbing the current script's URL from a stack trace to find the element: https://github.com/amiller-gh/currentScript-polyfill/blob/master/currentScript.js#L21
Did you test in-browser to confirm this does not work?
Hi. Yes I tested it. With this code:
<!doctype html>
<html lang="es">
<head>
<meta charset="utf-8">
<script src="currentScript.js"></script>
</head>
<body>
<script id="test2">
console.log(document.currentScript);
</script>
<form id="hola">
<script id="test">
console.log(document.currentScript);
</script>
</form>
</body>
</html>
EDGE/Internet Explorer 12 - OK
Internet Explorer 11 - returns null on console.
Internet Explorer 10 (emulated) - OK
Internet Explorer 9 (emulated) - OK
Internet Explorer 8 (emulated) - returns an int values (maybe the index on the scripts)
I think this polyfill only works for scripts with src
attribute in IE11
Nice! Looks like the README is now out of date though.
An exceptionally slim (~310b minified) polyfill for document.currentScript in IE9-IE10
@amiller-gh can we get the current version published to npm?
Should be fixed with the following pull-request: #5
hey @Schepp, this doesn't seem to work on IE11 as of right now, here's my test:
https://josueochoa.com/currentScript.html
Returns null
on both scripts.