Skip to content

Commit

Permalink
Patch Media: Remove event-listenever package and replaced with local …
Browse files Browse the repository at this point in the history
…function (#611)
  • Loading branch information
thetarnav authored Apr 9, 2024
2 parents 75c8762 + 5e1dd94 commit 3ab84fe
Show file tree
Hide file tree
Showing 5 changed files with 2,185 additions and 2,278 deletions.
8 changes: 6 additions & 2 deletions packages/media/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @solid-primitives/media

## 2.2.9

### Patch Changes

- Added warning regarding iOS13 support and instruction on how to polyfill

## 2.2.8

### Patch Changes
Expand Down Expand Up @@ -257,5 +263,3 @@ Added `makeMediaQueryListener`, implementation improvements
2.0.0

Add `usePrefersDark`.

Remove the default export. (`createMediaQuery` will only be available as named export)
16 changes: 16 additions & 0 deletions packages/media/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,26 @@ createEffect(() => {

> Note: `usePrefersDark` will deopt to `createPrefersDark` if used during hydration. (see issue [#310](https://github.com/solidjs-community/solid-primitives/issues/310))
## Notes
### iOS 13 Support & Deprecated `addListener`

Due to older versions of [mobile Safari on iOS 13 not supporting](https://github.com/mdn/sprints/issues/858) `addEventListener` on the MediaQueryList API, this primitive will need to be polyfilled. If your application needs to support much older versions of the browser you should [use a polyfill utility](https://www.npmjs.com/package/matchmedia-polyfill) or patch the missing function like so:

```ts
if (!'addEventListener' in MediaQueryList) {
MediaQueryList.prototype.addEventListener = function(type, callback) {
if (type === "change") this.addListener(callback)
}
MediaQueryList.prototype.removeEventListener = function(type, callback) {
if (type === "change") this.removeListener(callback)
}
}
```
## Changelog

See [CHANGELOG.md](./CHANGELOG.md)

## Contributors

Thanks to Aditya Agarwal for contributing createBreakpoints.

2 changes: 1 addition & 1 deletion packages/media/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solid-primitives/media",
"version": "2.2.8",
"version": "2.2.9",
"description": "Primitives for media query and device features",
"author": "David Di Biase <dave.dibiase@gmail.com>",
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion packages/media/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@ export function sortBreakpoints(breakpoints: Breakpoints): Breakpoints {
obj[key] = value;
return obj;
}, {});
}
}
Loading

0 comments on commit 3ab84fe

Please sign in to comment.