Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5a98e80

Browse files
jbedardpetebacondarwin
authored andcommitted
fix($compile): use createMap() for $$observe listeners when initialized from attr interpolation
Closes #10446
1 parent 808f984 commit 5a98e80

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
24272427
compile: function() {
24282428
return {
24292429
pre: function attrInterpolatePreLinkFn(scope, element, attr) {
2430-
var $$observers = (attr.$$observers || (attr.$$observers = {}));
2430+
var $$observers = (attr.$$observers || (attr.$$observers = createMap()));
24312431

24322432
if (EVENT_HANDLER_ATTR_REGEXP.test(name)) {
24332433
throw $compileMinErr('nodomevents',

test/ng/compileSpec.js

+16
Original file line numberDiff line numberDiff line change
@@ -3577,6 +3577,22 @@ describe('$compile', function() {
35773577
});
35783578
});
35793579

3580+
it('should be able to interpolate attribute names which are present in Object.prototype', function() {
3581+
var attrs;
3582+
module(function() {
3583+
directive('attrExposer', valueFn({
3584+
link: function($scope, $element, $attrs) {
3585+
attrs = $attrs;
3586+
}
3587+
}));
3588+
});
3589+
inject(function($compile, $rootScope) {
3590+
$compile('<div attr-exposer to-string="{{1 + 1}}">')($rootScope);
3591+
$rootScope.$apply();
3592+
expect(attrs.toString).toBe('2');
3593+
});
3594+
});
3595+
35803596

35813597
it('should not initialize scope value if optional expression binding is not passed', inject(function($compile) {
35823598
compile('<div my-component></div>');

0 commit comments

Comments
 (0)