Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit e54909f

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 79f2512 commit e54909f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docs/src/templates/doc_widgets.js

+6-1
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)