Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d489ff

Browse files
committed
fix(docs): use window.execScript instead of window.eval on IE
IE's window.eval doesn't execute in the global context, so we have to use window.execScript instead which works like window.eval on normal browsers. However execScript throws an exception when an empty string is passed in, so I created a workaround with a workaround.
1 parent fc5cda2 commit 2d489ff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docs/src/templates/doc_widgets.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@
5656
element.append(tabs);
5757

5858
var script = (exampleSrc.match(/<script[^\>]*>([\s\S]*)<\/script>/) || [])[1] || '';
59+
5960
try {
60-
window.eval(script);
61+
if (window.execScript) { // IE
62+
window.execScript(script || '"stupid IE!"'); // IE complains when evaling empty string
63+
} else {
64+
window.eval(script);
65+
}
6166
} catch (e) {
6267
alert(e);
6368
}

0 commit comments

Comments
 (0)