Skip to content

Commit 5394770

Browse files
committed
Fix bug in sandbox that caused it to disallow assuments to global let bindings
Closes marijnh#268
1 parent 117e942 commit 5394770

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

html/js/sandbox.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,10 @@
371371
catchPos = stat.end
372372
}
373373
if (stat.type == "VariableDeclaration" && stat.kind != "var") {
374-
let found = findAssignmentsTo(stat.declarations, ast)
375-
if (found) patches.push({from: 0, text: `throw new TypeError("invalid assignment to const '${found}'");`})
374+
if (stat.kind == "const") {
375+
let found = findAssignmentsTo(stat.declarations, ast)
376+
if (found) patches.push({from: 0, text: `throw new TypeError("invalid assignment to const '${found}'");`})
377+
}
376378
patches.push({from: stat.start, to: stat.start + stat.kind.length, text: "var"})
377379
}
378380
if (stat.type == "ClassDeclaration")

0 commit comments

Comments
 (0)