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

fix($compile): make '='-bindings NaN-aware #8554

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
if (parentGet.literal) {
compare = equals;
} else {
compare = function(a,b) { return a === b; };
compare = function(a,b) { return a === b || (a !== a && b !== b); };
}
parentSet = parentGet.assign || function() {
// reset the change, or we will throw this exception on every $digest
Expand Down
22 changes: 22 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2869,6 +2869,28 @@ describe('$compile', function() {
});


it('should update parent scope when "="-bound NaN changes', inject(function($compile, $rootScope) {
$rootScope.num = NaN;
compile('<div my-component reference="num"></div>');
var isolateScope = element.isolateScope();
expect(isolateScope.reference).toBeNaN();

isolateScope.$apply(function(scope) { scope.reference = 64; });
expect($rootScope.num).toBe(64);
}));


it('should update isolate scope when "="-bound NaN changes', inject(function($compile, $rootScope) {
$rootScope.num = NaN;
compile('<div my-component reference="num"></div>');
var isolateScope = element.isolateScope();
expect(isolateScope.reference).toBeNaN();

$rootScope.$apply(function(scope) { scope.num = 64; });
expect(isolateScope.reference).toBe(64);
}));


describe('bind-once', function () {

function countWatches(scope) {
Expand Down