aboutsummaryrefslogtreecommitdiffstats
path: root/src/Scope.js
diff options
context:
space:
mode:
authorMisko Hevery2010-03-22 20:20:05 -0700
committerMisko Hevery2010-03-22 20:20:05 -0700
commita8227086748e37c31c1bb71dec50c96d63c45eef (patch)
tree80979da4e4124b57fa4962baf58bb326964b658e /src/Scope.js
parent7c87c17d08dbba318af1a149c0bbedb696b03458 (diff)
downloadangular.js-a8227086748e37c31c1bb71dec50c96d63c45eef.tar.bz2
rudementary event bind and trigger for jqlite
Diffstat (limited to 'src/Scope.js')
-rw-r--r--src/Scope.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Scope.js b/src/Scope.js
index 7b1d2673..a3e128b6 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -73,7 +73,7 @@ Scope.prototype = {
// todo: this is a hack, which will need to be cleaned up.
var self = this,
listenFn = listener || noop,
- expr = bind(self, self.compile(fn), {scope: self, self: self.state});
+ expr = self.compile(fn);
this.evals.push(function(){
self.apply(listenFn, expr());
});
@@ -117,23 +117,24 @@ Scope.prototype = {
compile: function(exp) {
if (isFunction(exp)) return exp;
- var expFn = Scope.expressionCache[exp];
+ var expFn = Scope.expressionCache[exp], self = this;
if (!expFn) {
var parser = new Parser(exp);
expFn = parser.statements();
parser.assertAllConsumed();
Scope.expressionCache[exp] = expFn;
}
- return expFn;
+ return function(context){
+ context = context || {};
+ context.self = self.state;
+ context.scope = self;
+ return expFn.call(self, context);
+ };
},
eval: function(expressionText, context) {
// log('Scope.eval', expressionText);
- var expression = this.compile(expressionText);
- context = context || {};
- context.scope = this;
- context.self = this.state;
- return expression(context);
+ return this.compile(expressionText)(context);
},
//TODO: Refactor. This function needs to be an execution closure for widgets
@@ -209,7 +210,7 @@ Scope.prototype = {
addWatchListener: function(watchExpression, listener) {
// TODO: clean me up!
if (!isFunction(listener)) {
- listener = bind(this, this.compile(listener), {scope: this, self: this.state});
+ listener = this.compile(listener);
}
var watcher = this.watchListeners[watchExpression];
if (!watcher) {