Skip to content

Commit 1cb8d52

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 angular#14070
1 parent 0348347 commit 1cb8d52

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/ng/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3122,7 +3122,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
31223122
destination[scopeName] = attrs[attrName] = void 0;
31233123
}
31243124
attrs.$observe(attrName, function(value) {
3125-
if (isString(value)) {
3125+
if (isString(value) || isBoolean(value)) {
31263126
var oldValue = destination[scopeName];
31273127
recordChanges(scopeName, value, oldValue);
31283128
destination[scopeName] = value;

test/ng/compileSpec.js

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

27172736

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy