Permalink
Browse files

Fix closured variables being modified in the wrong scope.

  • Loading branch information...
1 parent 1b7be18 commit 2dbfecf8869738c1bc00089b87db716af2bdc825 @csnover committed Jan 3, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/Scope.js
View
@@ -135,7 +135,8 @@ define([ 'dojo/_base/lang', './env', './Value', './node!util' ], function (lang,
if (!variable) {
console.warn(name.join('.') + ': Implicit global variable declaration');
- variable = env.globalScope.addVariable(name[0]);
+ scope = env.globalScope;
+ variable = scope.addVariable(name[0]);
}
}
@@ -144,11 +145,11 @@ define([ 'dojo/_base/lang', './env', './Value', './node!util' ], function (lang,
throw new Error('Cannot assign to "this"');
}
- if (this.vars[name[0]] && this.vars[name[0]].type !== 'undefined' && this.vars[name[0]] !== value) {
- console.info(name.join('.') + ': Changing value reference from ' + this.vars[name[0]] + ' to ' + value);
+ if (scope.vars[name[0]] && scope.vars[name[0]].type !== 'undefined' && scope.vars[name[0]] !== value) {
+ console.info(name.join('.') + ': Changing value reference from ' + scope.vars[name[0]] + ' to ' + value);
}
- this.vars[name[0]] = value;
+ scope.vars[name[0]] = value;
}
else {
// Attempt to set a complex expression

0 comments on commit 2dbfecf

Please sign in to comment.