aboutsummaryrefslogtreecommitdiffstats
path: root/src/Scope.js
diff options
context:
space:
mode:
authorMisko Hevery2010-09-21 19:20:34 +0200
committerMisko Hevery2010-09-21 19:20:34 +0200
commit006fd2ca252400e87a419b929e00ea0277ff86ad (patch)
treefcf3c021aa5c1e95dc2a43cc0d3f019b541d3ce5 /src/Scope.js
parent125d725e7dcd76b838925ac997b35afad4266752 (diff)
downloadangular.js-006fd2ca252400e87a419b929e00ea0277ff86ad.tar.bz2
HEAD is now at 10c0151 Fixes on issue when a SELECT has OPTION which are data bound (ie OPTION has repeater or OPTION.value is bound), then SELECT does not update to match the correct OPTION after the change in model (ie after the OPTION repeater unrolls or OPTION.value is changed.)
Diffstat (limited to 'src/Scope.js')
-rw-r--r--src/Scope.js40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/Scope.js b/src/Scope.js
index c2a4f098..53228a0d 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -22,7 +22,7 @@ function getter(instance, path, unboundFn) {
}
}
}
- if (!unboundFn && isFunction(instance) && !instance['$$factory']) {
+ if (!unboundFn && isFunction(instance)) {
return bind(lastInstance, instance);
}
return instance;
@@ -113,12 +113,13 @@ function createScope(parent, services, existing) {
function API(){}
function Behavior(){}
- var instance, behavior, api, evalLists = {sorted:[]}, servicesCache = extend({}, existing);
-
parent = Parent.prototype = (parent || {});
- api = API.prototype = new Parent();
- behavior = Behavior.prototype = new API();
- instance = new Behavior();
+ var evalLists = {sorted:[]};
+ var postList = [], postHash = {}, postId = 0;
+ var servicesCache = extend({}, existing);
+ var api = API.prototype = new Parent();
+ var behavior = Behavior.prototype = new API();
+ var instance = new Behavior();
extend(api, {
'this': instance,
@@ -130,14 +131,23 @@ function createScope(parent, services, existing) {
$eval: function $eval(exp) {
var type = typeof exp;
+ var i, iSize;
+ var j, jSize;
+ var queue;
+ var fn;
if (type == $undefined) {
- for ( var i = 0, iSize = evalLists.sorted.length; i < iSize; i++) {
- for ( var queue = evalLists.sorted[i],
+ for ( i = 0, iSize = evalLists.sorted.length; i < iSize; i++) {
+ for ( queue = evalLists.sorted[i],
jSize = queue.length,
j= 0; j < jSize; j++) {
instance.$tryEval(queue[j].fn, queue[j].handler);
}
}
+ while(postList.length) {
+ fn = postList.shift();
+ delete postHash[fn.$postEvalId];
+ instance.$tryEval(fn);
+ }
} else if (type === $function) {
return exp.call(instance);
} else if (type === 'string') {
@@ -202,6 +212,20 @@ function createScope(parent, services, existing) {
});
},
+ $postEval: function(expr) {
+ if (expr) {
+ var fn = expressionCompile(expr);
+ var id = fn.$postEvalId;
+ if (!id) {
+ id = '$' + instance.$id + "_" + (postId++);
+ fn.$postEvalId = id;
+ }
+ if (!postHash[id]) {
+ postList.push(postHash[id] = fn);
+ }
+ }
+ },
+
$become: function(Class) {
// remove existing
foreach(behavior, function(value, key){ delete behavior[key]; });