aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/parseSpec.js
diff options
context:
space:
mode:
authorLucas Galfasó2014-01-17 14:59:49 -0300
committerCaitlin Potter2014-01-21 19:27:04 -0500
commitf09b6aa5b58c090e3b8f8811fb7735e38d4b7623 (patch)
tree6a51f29702aec862c2a4db337f85b5aa193ec5a3 /test/ng/parseSpec.js
parent8b395ff3258526d9f395b828874eac7a4b5f46e5 (diff)
downloadangular.js-f09b6aa5b58c090e3b8f8811fb7735e38d4b7623.tar.bz2
fix($parse): do not use locals to resolve object properties
Do not use the locals when performing a field access in an angular expression. Closes #5838 Closes #5862
Diffstat (limited to 'test/ng/parseSpec.js')
-rw-r--r--test/ng/parseSpec.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js
index 7d4642d1..24f5c950 100644
--- a/test/ng/parseSpec.js
+++ b/test/ng/parseSpec.js
@@ -358,7 +358,7 @@ describe('parser', function() {
forEach([2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 42, 99], function(pathLength) {
it('should resolve nested paths of length ' + pathLength, function() {
// Create a nested object {x2: {x3: {x4: ... {x[n]: 42} ... }}}.
- var obj = 42;
+ var obj = 42, locals = {};
for (var i = pathLength; i >= 2; i--) {
var newObj = {};
newObj['x' + i] = obj;
@@ -371,6 +371,8 @@ describe('parser', function() {
path += '.x' + i;
}
expect(scope.$eval(path)).toBe(42);
+ locals['x' + pathLength] = 'not 42'
+ expect(scope.$eval(path, locals)).toBe(42);
});
});
@@ -938,6 +940,13 @@ describe('parser', function() {
expect($parse('a.b')({a: {b: 0}}, {a: null})).toEqual(undefined);
expect($parse('a.b.c')({a: null}, {a: {b: {c: 1}}})).toEqual(1);
}));
+
+ it('should not use locals to resolve object properties', inject(function($parse) {
+ expect($parse('a[0].b')({a: [ {b : 'scope'} ]}, {b : 'locals'})).toBe('scope');
+ expect($parse('a[0]["b"]')({a: [ {b : 'scope'} ]}, {b : 'locals'})).toBe('scope');
+ expect($parse('a[0][0].b')({a: [[{b : 'scope'}]]}, {b : 'locals'})).toBe('scope');
+ expect($parse('a[0].b.c')({a: [ {b: {c: 'scope'}}] }, {b : {c: 'locals'} })).toBe('scope');
+ }));
});
describe('literal', function() {