diff options
| author | Shyam Seshadri | 2010-08-10 19:10:43 -0700 | 
|---|---|---|
| committer | Shyam Seshadri | 2010-08-10 19:10:43 -0700 | 
| commit | e7b90956552bc129935e7b8dec947eb3e30f3c29 (patch) | |
| tree | ab0fadb7a544a931a6eed9183bf884360e2d6393 /src/scenario | |
| parent | c4c96c5c69846fb8eccc278c1eb20f94d69a2b99 (diff) | |
| download | angular.js-e7b90956552bc129935e7b8dec947eb3e30f3c29.tar.bz2 | |
Change repeater dsl to collect and return an array of string contents based on match
Diffstat (limited to 'src/scenario')
| -rw-r--r-- | src/scenario/DSL.js | 39 | 
1 files changed, 24 insertions, 15 deletions
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js index 96447aaf..2dd37250 100644 --- a/src/scenario/DSL.js +++ b/src/scenario/DSL.js @@ -43,6 +43,8 @@ angular.scenario.dsl.input = function(selector) {    };  }, +angular.scenario.dsl.NG_BIND_PATTERN =/\{\{[^\}]+\}\}/; +  angular.scenario.dsl.repeater = function(selector) {    var namePrefix = "repeater '" + selector + "'";    return { @@ -51,23 +53,30 @@ angular.scenario.dsl.repeater = function(selector) {            done(this.testDocument.find(selector).size());        });      }, -    collect: function() { -      return $scenario.addFuture(namePrefix + ' collect', function(done) { +    collect: function(collectSelector) { +      return $scenario.addFuture( +          namePrefix + " collect '" + collectSelector + "'", +          function(done) {          var self = this;          var doCollect = bind(this, function() { -          var repeaterArray = []; +          var repeaterArray = [], ngBindPattern; +          var startIndex = collectSelector.search( +              angular.scenario.dsl.NG_BIND_PATTERN); +          if (startIndex >= 0) { +            ngBindPattern = collectSelector.substring( +                startIndex + 2, collectSelector.length - 2); +            collectSelector = '*'; +             +          }            this.testDocument.find(selector).each(function() { -            var element = angular.extend(self.jQuery(this), -                {bindings: [], -                 boundTo: function(name) { return this.bindings[name]; }} -            ); -            element.find('*').each(function() { -              var bindName = self.jQuery(this).attr('ng:bind'); -              if (bindName) { -                element.bindings[bindName] = self.jQuery(this).text(); -              } +            var element = self.jQuery(this); +            element.find(collectSelector). +              each(function() { +                var foundElem = self.jQuery(this); +                if (foundElem.attr('ng:bind') == ngBindPattern) { +                  repeaterArray.push(foundElem.text()); +                }              }); -            repeaterArray[index] = element;            });            return repeaterArray;          }); @@ -86,9 +95,9 @@ angular.scenario.dsl.element = function(selector) {        boundTo: function(name) { return this.bindings[name]; }      });      element.find('*').each(function() { -      var bindName = self.jQuery(elem).attr('ng:bind'); +      var bindName = self.jQuery(this).attr('ng:bind');        if (bindName) { -        element.bindings[bindName] = self.jQuery(elem).text(); +        element.bindings[bindName] = self.jQuery(this).text();        }      });      done(element);  | 
