Skip to content
Open
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
6 changes: 5 additions & 1 deletion src/useMediaQuery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const createQueryEntry = (query: string) => {
}
};

mql.addEventListener('change', listener, {passive: true});
if (mql.addEventListener) {
mql.addEventListener('change', listener, {passive: true});
} else {
mql.addListener(listener);
}
Comment on lines +20 to +24
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding test coverage for the legacy addListener/removeListener compatibility path. The current tests only mock addEventListener and removeEventListener. Adding a test that mocks a MediaQueryList without addEventListener would ensure this compatibility code path is tested.

Copilot uses AI. Check for mistakes.

return {
mql,
Expand Down
Loading