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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 19 additions & 0 deletions
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)
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