diff options
| author | Caitlin Potter | 2014-01-07 16:41:54 -0500 | 
|---|---|---|
| committer | Caitlin Potter | 2014-02-21 17:58:48 -0500 | 
| commit | 5fe1f39f027c6f2c6a530975dd5389d788d3c0eb (patch) | |
| tree | 01e1ce824f01a03418d8ea74326e3998959c64fa | |
| parent | 2bce71e9dc10c8588f9eb599a0cd2e831440fc48 (diff) | |
| download | angular.js-5fe1f39f027c6f2c6a530975dd5389d788d3c0eb.tar.bz2 | |
fix($parse): reduce false-positives in isElement tests
There are always going to be false positives here, unfortunately. But
testing different properties will hopefully reduce the number of false
positives in a meaningful way, without harming performance too much.
Closes #4805
Closes #5675
| -rw-r--r-- | src/ng/parse.js | 2 | ||||
| -rw-r--r-- | test/ng/parseSpec.js | 22 | 
2 files changed, 23 insertions, 1 deletions
| diff --git a/src/ng/parse.js b/src/ng/parse.js index 043be76c..bd3aa048 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -55,7 +55,7 @@ function ensureSafeObject(obj, fullExpression) {            'Referencing the Window in Angular expressions is disallowed! Expression: {0}',            fullExpression);      } else if (// isElement(obj) -        obj.children && (obj.nodeName || (obj.on && obj.find))) { +        obj.children && (obj.nodeName || (obj.prop && obj.attr && obj.find))) {        throw $parseMinErr('isecdom',            'Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}',            fullExpression); diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js index 24f5c950..466be755 100644 --- a/test/ng/parseSpec.js +++ b/test/ng/parseSpec.js @@ -786,6 +786,28 @@ describe('parser', function() {                        '$parse', 'isecdom', 'Referencing DOM nodes in Angular expressions is ' +                        'disallowed! Expression: a.b.doc.on("click")');              })); + +            // Issue #4805 +            it('should NOT throw isecdom when referencing a Backbone Collection', function() { +              // Backbone stuff is sort of hard to mock, if you have a better way of doing this, +              // please fix this. +              var fakeBackboneCollection = { +                children: [{}, {}, {}], +                find: function() {}, +                on: function() {}, +                off: function() {}, +                bind: function() {} +              }; +              scope.backbone = fakeBackboneCollection; +              expect(function() { scope.$eval('backbone'); }).not.toThrow(); +            }); + +            it('should NOT throw isecdom when referencing an array with node properties', function() { +              var array = [1,2,3]; +              array.on = array.attr = array.prop = array.bind = true; +              scope.array = array; +              expect(function() { scope.$eval('array'); }).not.toThrow(); +            });            });          }); | 
