Skip to content

Commit

Permalink
fix(common): properly check NaN value (#22305)
Browse files Browse the repository at this point in the history
closes #15721

PR Close #22305
  • Loading branch information
trotyl authored and benlesh committed Apr 20, 2019
1 parent c3c0df9 commit 3f6bf6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/common/src/pipes/async_pipe.ts
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ChangeDetectorRef, EventEmitter, Injectable, OnDestroy, Pipe, PipeTransform, WrappedValue, ɵisObservable, ɵisPromise} from '@angular/core';
import {ChangeDetectorRef, EventEmitter, Injectable, OnDestroy, Pipe, PipeTransform, WrappedValue, ɵisObservable, ɵisPromise, ɵlooseIdentical} from '@angular/core';
import {Observable, SubscriptionLike} from 'rxjs';
import {invalidPipeArgumentError} from './invalid_pipe_argument_error';

Expand Down Expand Up @@ -103,7 +103,7 @@ export class AsyncPipe implements OnDestroy, PipeTransform {
return this.transform(obj as any);
}

if (this._latestValue === this._latestReturnedValue) {
if (ɵlooseIdentical(this._latestValue, this._latestReturnedValue)) {
return this._latestReturnedValue;
}

Expand Down
12 changes: 12 additions & 0 deletions packages/common/test/pipes/async_pipe_spec.ts
Expand Up @@ -82,6 +82,18 @@ import {SpyChangeDetectorRef} from '../spies';
async.done();
}, 10);
}));

it('should return unwrapped value for unchanged NaN', () => {
const emitter = new EventEmitter<any>();
emitter.emit(null);
pipe.transform(emitter);
emitter.next(NaN);
const firstResult = pipe.transform(emitter);
const secondResult = pipe.transform(emitter);
expect(firstResult instanceof WrappedValue).toBe(true);
expect((firstResult as WrappedValue).wrapped).toBeNaN();
expect(secondResult).toBeNaN();
});
});

describe('ngOnDestroy', () => {
Expand Down

0 comments on commit 3f6bf6d

Please sign in to comment.