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:
committed by
Georgios Kalpakas
parent
0348347841
commit
1cb8d529a6
+1
-1
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user