From b1246bf672885ef4a4b1dab385272bb6da9d53f9 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Sat, 13 Dec 2014 16:24:24 -0800 Subject: [PATCH] fix($compile): use createMap() for $$observe listeners when initialized from attr interpolation --- src/ng/compile.js | 2 +- test/ng/compileSpec.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 34e38137606f..c2cff4fd4db2 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -2359,7 +2359,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { compile: function() { return { pre: function attrInterpolatePreLinkFn(scope, element, attr) { - var $$observers = (attr.$$observers || (attr.$$observers = {})); + var $$observers = (attr.$$observers || (attr.$$observers = createMap())); if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { throw $compileMinErr('nodomevents', diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 908739c447a0..a7f2dd08ac84 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -3274,6 +3274,22 @@ describe('$compile', function() { }); }); + it('should be able to interpolate attribute names which are present in Object.prototype', function() { + var attrs; + module(function() { + directive('attrExposer', valueFn({ + link: function($scope, $element, $attrs) { + attrs = $attrs; + } + })); + }); + inject(function($compile, $rootScope) { + $compile('
')($rootScope); + $rootScope.$apply(); + expect(attrs.toString).toBe('2'); + }); + }); + it('should not initialize scope value if optional expression binding is not passed', inject(function($compile) { compile('
');