Skip to content

Commit 7891e19

Browse files
authored
fix(cdk/collections): ConnectableObservable incorrectly inferred as data source (#25526)
The `isDataSource` function determines that something is a data source by checking if it has a `connect` method. The problem is that rxjs has a `ConnectableObservable` which also has a `connect` method and which gets incorrectly identified as a data source. Fixes #25483.
1 parent e63390c commit 7891e19

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/cdk/collections/data-source.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Observable} from 'rxjs';
9+
import {ConnectableObservable, Observable} from 'rxjs';
1010
import {CollectionViewer} from './collection-viewer';
1111

1212
export abstract class DataSource<T> {
@@ -34,6 +34,7 @@ export abstract class DataSource<T> {
3434
export function isDataSource(value: any): value is DataSource<any> {
3535
// Check if the value is a DataSource by observing if it has a connect function. Cannot
3636
// be checked as an `instanceof DataSource` since people could create their own sources
37-
// that match the interface, but don't extend DataSource.
38-
return value && typeof value.connect === 'function';
37+
// that match the interface, but don't extend DataSource. We also can't use `isObservable`
38+
// here, because of some internal apps.
39+
return value && typeof value.connect === 'function' && !(value instanceof ConnectableObservable);
3940
}

0 commit comments

Comments
 (0)