Skip to content

Commit 2e69c07

Browse files
committed
move js autorun to global context
1 parent 04f1da4 commit 2e69c07

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

client/prism/codeBox.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,24 @@ function CodeBox(elem) {
165165

166166
}
167167

168+
// Evaluates a script in a global context
169+
function globalEval( code ) {
170+
var script = document.createElement( "script" );
171+
script.text = code;
172+
document.head.appendChild( script ).parentNode.removeChild( script );
173+
}
174+
168175
function runJS() {
169176

170-
console.log(code);
177+
//console.log(code);
171178
if (isTrusted) {
172179

180+
if (elem.hasAttribute('data-autorun')) {
181+
// make sure functions from "autorun" go to global scope
182+
globalEval(code);
183+
return;
184+
}
185+
173186
try {
174187
/* jshint -W061 */
175188
window["eval"].call(window, code);

0 commit comments

Comments
 (0)