From e091c273bbd17603d410fecc363874f0d1e6f38e Mon Sep 17 00:00:00 2001 From: Chris Tucker Date: Tue, 15 Oct 2013 18:13:46 -0700 Subject: [PATCH] Consume binders array as we process it. Ensures that we both process newly added binders from bo-if, and that we only process each binder once. --- bindonce.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/bindonce.js b/bindonce.js index 33f123f..bf72efe 100644 --- a/bindonce.js +++ b/bindonce.js @@ -101,15 +101,13 @@ } }, - runBinders: function () + runBinders : function() { - var i, max; - for (i = 0, max = this.binders.length; i < max; i++) - { - var binder = this.binders[i]; - if (this.group && this.group !== binder.group) continue; + while(this.binders.length > 0) { + var binder = this.binders.shift(); + if (this.group && this.group != binder.group ) continue; var value = binder.scope.$eval((binder.interpolate) ? $interpolate(binder.value) : binder.value); - switch (binder.attr) + switch(binder.attr) { case 'if': if (toBoolean(value)) @@ -269,4 +267,4 @@ return bindonceDirective; }); }); -})(); \ No newline at end of file +})();