Skip to content
Permalink
Browse files

fix($compile): use createMap() for $$observe listeners when initializ…

…ed from attr interpolation
  • Loading branch information
jbedard authored and lgalfaso committed Dec 14, 2014
1 parent ab41e48 commit 8e28bb4c2f6d015dfe1cec7755f1ca9b0ecef1f8
Showing with 18 additions and 1 deletion.
  1. +1 −1 src/ng/compile.js
  2. +17 −0 test/ng/compileSpec.js
@@ -2355,7 +2355,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',
@@ -3218,6 +3218,23 @@ 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('<div attr-exposer to-string="{{1 + 1}}" has-own-property="{{1 + 1}}">')($rootScope);
$rootScope.$apply();
expect(attrs.toString).toBe('2');
expect(attrs.hasOwnProperty).toBe('2');
});
});


describe('bind-once', function() {

0 comments on commit 8e28bb4

Please sign in to comment.
You can’t perform that action at this time.