From 9f919c42f0885e39870195fab8ce2a22621119b7 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 4 Feb 2010 14:02:20 -0800 Subject: better handling of $invalidWidgets --- src/Angular.js | 1 + src/Binder.js | 2 +- src/Scope.js | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Angular.js b/src/Angular.js index ded4485f..fa6a610c 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -294,6 +294,7 @@ function wireAngular(element, config) { '$anchor' : binder.anchor, '$updateView': _(binder.updateView).bind(binder), '$config' : config, + '$invalidWidgets': [], '$console' : window.console, '$datastore' : exposeMethods(datastore, { 'load': datastore.load, diff --git a/src/Binder.js b/src/Binder.js index e516ec32..8dac934b 100644 --- a/src/Binder.js +++ b/src/Binder.js @@ -95,7 +95,7 @@ Binder.prototype = { updateView: function() { var start = new Date().getTime(); var scope = jQuery(this.doc).scope(); - scope.set("$invalidWidgets", []); + scope.clearInvalid(); scope.updateView(); var end = new Date().getTime(); this.updateAnchor(); diff --git a/src/Scope.js b/src/Scope.js index b8fadfa0..cedb0542 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -153,6 +153,11 @@ Scope.prototype = { return expression({scope:this, datastore:datastore}); }, + clearInvalid: function() { + var invalid = this.state['$invalidWidgets']; + while(invalid.length > 0) {invalid.pop();} + }, + markInvalid: function(widget) { this.state['$invalidWidgets'].push(widget); }, -- cgit v1.2.3