fix($compile): handle boolean attributes in @ bindings

Commit db5e0ff handles initial values of boolean attributes. The same
change needs to be applied inside the attrs.$observe() call.

Closes #14070
This commit is contained in:
Jan Niehusmann
2016-02-17 17:40:01 +01:00
committed by Georgios Kalpakas
parent 0348347841
commit 1cb8d529a6
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -3122,7 +3122,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
destination[scopeName] = attrs[attrName] = void 0;
}
attrs.$observe(attrName, function(value) {
if (isString(value)) {
if (isString(value) || isBoolean(value)) {
var oldValue = destination[scopeName];
recordChanges(scopeName, value, oldValue);
destination[scopeName] = value;
+19
View File
@@ -2712,6 +2712,25 @@ describe('$compile', function() {
expect(checkedVal).toEqual(true);
});
});
it('should handle updates to @ bindings on BOOLEAN attributes', function() {
var componentScope;
module(function($compileProvider) {
$compileProvider.directive('test', function() {
return {
scope: {checked: '@'},
link: function(scope, element, attrs) {
componentScope = scope;
attrs.$set('checked', true);
}
};
});
});
inject(function($compile, $rootScope) {
$compile('<test></test>')($rootScope);
expect(componentScope.checked).toBe(true);
});
});
});