From d934054cfc22325d817eb0643dc061f9d212804d Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 25 Mar 2010 22:03:11 -0700 Subject: major refactoring of scope --- src/Compiler.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/Compiler.js') diff --git a/src/Compiler.js b/src/Compiler.js index 47ab0c14..3b492ebe 100644 --- a/src/Compiler.js +++ b/src/Compiler.js @@ -14,7 +14,7 @@ Template.prototype = { init: function(element, scope) { element = jqLite(element); foreach(this.inits, function(fn) { - scope.apply(fn, element); + scope.$tryEval(fn, element, element); }); var i, @@ -92,14 +92,11 @@ Compiler.prototype = { rawElement = jqLite(rawElement); var template = this.templatize(rawElement) || new Template(); return function(element, parentScope){ - var scope = new Scope(parentScope); - scope.element = element; - // todo return should be a scope with everything already set on it as element - return { - scope: scope, - element:element, - init: bind(template, template.init, element, scope) - }; + var model = scope(parentScope); + return extend(model, { + $element:element, + $init: bind(template, template.init, element, model) + }); }; }, @@ -144,7 +141,7 @@ Compiler.prototype = { exclusive = true; directiveQueue = []; } - directiveQueue.push(bindTry(selfApi, directive, value, element, errorHandlerFor(element))); + directiveQueue.push(bind(selfApi, directive, value, element)); } }); -- cgit v1.2.3