mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
fix($compile): use createMap() for $$observe listeners when initialized from attr interpolation
This commit is contained in:
committed by
Lucas Galfaso
parent
ab41e48493
commit
8e28bb4c2f
@@ -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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user