From bb822b3ed0417a73989ead394efe4ed5836bcb79 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 9 Jan 2024 13:32:30 -0500 Subject: [PATCH] chore: remove matchMedia check (#28783) Issue number: Internal --------- ## What is the current behavior? As part of FW-2832 the team has an initiative to remove much of the `any` usage in favor of stronger types. This will make modifications to this codebase safer as we will have access to proper type checking. ## What is the new behavior? - Removed the `any` case from window.matchMedia. This causes the linter to fail because `window.matchMedia` is always defined. I removed the check altogether. `matchMedia` is supported on all browsers that Ionic 7 supports. This should not cause any changes for Ionic developers, but I want to ship this a) in a separate patch and b) in a minor release to de-risk just in case there's an edge case I am not considering ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information --- core/src/components/split-pane/split-pane.tsx | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/core/src/components/split-pane/split-pane.tsx b/core/src/components/split-pane/split-pane.tsx index decd5d7a59..f40fa75644 100644 --- a/core/src/components/split-pane/split-pane.tsx +++ b/core/src/components/split-pane/split-pane.tsx @@ -112,17 +112,16 @@ export class SplitPane implements ComponentInterface { return; } - if ((window as any).matchMedia) { - // Listen on media query - const callback = (q: MediaQueryList) => { - this.visible = q.matches; - }; - - const mediaList = window.matchMedia(mediaQuery); - (mediaList as any).addListener(callback as any); - this.rmL = () => (mediaList as any).removeListener(callback as any); - this.visible = mediaList.matches; - } + // Listen on media query + const callback = (q: MediaQueryList) => { + this.visible = q.matches; + }; + + const mediaList = window.matchMedia(mediaQuery); + // TODO FW-5869 + (mediaList as any).addListener(callback as any); + this.rmL = () => (mediaList as any).removeListener(callback as any); + this.visible = mediaList.matches; } private isPane(element: HTMLElement): boolean {