Skip to content

Commit b7c04fb

Browse files
committed
omg don't forget to .bind(this) or else 'this' will be the global Window
object when called, ergh subtle!
1 parent 395925b commit b7c04fb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎v3/js/pytutor.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4820,7 +4820,9 @@ ExecutionVisualizer.prototype.activateJavaFrontend = function() {
48204820
});
48214821

48224822
// java synthetics cause things which javascript doesn't like in an id
4823-
var old_generateID = ExecutionVisualizer.prototype.generateID;
4823+
4824+
// VERY important to bind(this) so that when it's called, 'this' is this current object
4825+
var old_generateID = ExecutionVisualizer.prototype.generateID.bind(this);
48244826
this.generateID = function(original_id) {
48254827
var sanitized = original_id.replace(
48264828
/[^0-9a-zA-Z_]/g,

0 commit comments

Comments
 (0)