Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
Temzasse committed Nov 15, 2022
1 parent 70dc38a commit 962a8cf
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/internals/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,23 @@ function matchMediaRangeQuery(query, windowWidth) {
return result;
}

export function resolveMediaRangeQuery(queryObjects, windowWidth) {
const iterator = Object.entries(queryObjects);
export function resolveMediaRangeQuery(media, windowWidth) {
const entries = Object.entries(media);
let result;
for (let i = 0; i < iterator.length; i++) {
const [key, query] = iterator[i];
if (typeof query !== 'string') continue;
const match = matchMediaRangeQuery(query, windowWidth);

for (let i = 0; i < entries.length; i++) {
const [breakpoint, queryOrFlag] = entries[i];

// TODO: handle boolean flag
if (typeof queryOrFlag !== 'string') continue;

const match = matchMediaRangeQuery(queryOrFlag, windowWidth);

if (match) {
result = key;
result = breakpoint;
}
}

return result;
}

Expand Down

0 comments on commit 962a8cf

Please sign in to comment.