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

Commit 499e1b2

Browse files
jannicgkalpak
authored andcommitted
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
1 parent 28c6c4d commit 499e1b2

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3135,7 +3135,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
31353135
destination[scopeName] = attrs[attrName] = void 0;
31363136
}
31373137
attrs.$observe(attrName, function(value) {
3138-
if (isString(value)) {
3138+
if (isString(value) || isBoolean(value)) {
31393139
var oldValue = destination[scopeName];
31403140
recordChanges(scopeName, value, oldValue);
31413141
destination[scopeName] = value;

test/ng/compileSpec.js

+19
Original file line numberDiff line numberDiff line change
@@ -2711,6 +2711,25 @@ describe('$compile', function() {
27112711
expect(checkedVal).toEqual(true);
27122712
});
27132713
});
2714+
2715+
it('should handle updates to @ bindings on BOOLEAN attributes', function() {
2716+
var componentScope;
2717+
module(function($compileProvider) {
2718+
$compileProvider.directive('test', function() {
2719+
return {
2720+
scope: {checked: '@'},
2721+
link: function(scope, element, attrs) {
2722+
componentScope = scope;
2723+
attrs.$set('checked', true);
2724+
}
2725+
};
2726+
});
2727+
});
2728+
inject(function($compile, $rootScope) {
2729+
$compile('<test></test>')($rootScope);
2730+
expect(componentScope.checked).toBe(true);
2731+
});
2732+
});
27142733
});
27152734

27162735

0 commit comments

Comments
 (0)