Skip to content

Commit

Permalink
#921@trivial: Continues on implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
capricorn86 committed May 16, 2023
1 parent 6c80625 commit 221e7b0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/happy-dom/src/match-media/MediaQueryParser.ts
Expand Up @@ -13,6 +13,11 @@ import IWindow from '../window/IWindow';
*/
const MEDIA_QUERY_REGEXP = /(not|only|all|screen|print)|\(([^\)]+)(\)){0,1}|(,)| +(or|and) +/g;

/**
* Check if resolution RegExp.
*/
const IS_RESOLUTION_REGEXP = /[<>]/;

/**
* Resolution RegExp.
*
Expand Down Expand Up @@ -53,10 +58,9 @@ export default class MediaQueryParser {
} else if (match[1] === 'not') {
currentMediaQueryItem.not = true;
} else if (match[2]) {
const resolutionMatch =
match[2].includes('<') || match[2].includes('>')
? match[2].match(RESOLUTION_REGEXP)
: null;
const resolutionMatch = IS_RESOLUTION_REGEXP.test(match[2])
? match[2].match(RESOLUTION_REGEXP)
: null;
if (resolutionMatch && (resolutionMatch[1] || resolutionMatch[6])) {
if (resolutionMatch[1] && resolutionMatch[2] && resolutionMatch[3]) {
const value = parseInt(resolutionMatch[1], 10);
Expand Down

0 comments on commit 221e7b0

Please sign in to comment.