mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-05-23 03:23:51 +08:00
fix($parse): Allow property names that collide with native object properties
I.e. constructor, toString, or watch on FF (https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/watch) + optimize parser a bit to not create getter function for operators
This commit is contained in:
@@ -227,6 +227,17 @@ describe('parser', function() {
|
||||
expect(scope.$eval("x.y.z", scope)).not.toBeDefined();
|
||||
});
|
||||
|
||||
it('should support property names that colide with native object properties', function() {
|
||||
// regression
|
||||
scope.watch = 1;
|
||||
scope.constructor = 2;
|
||||
scope.toString = 3;
|
||||
|
||||
expect(scope.$eval('watch', scope)).toBe(1);
|
||||
expect(scope.$eval('constructor', scope)).toBe(2);
|
||||
expect(scope.$eval('toString', scope)).toBe(3);
|
||||
});
|
||||
|
||||
it('should evaluate grouped expressions', function() {
|
||||
expect(scope.$eval("(1+2)*3")).toEqual((1+2)*3);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user