Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 583ee45

Browse files
committed
Fixes #179 (including tests)
1 parent 5487dff commit 583ee45

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/respond.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
urls: /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,
5656
findStyles: /@media *([^\{]+)\{([\S\s]+?)$/,
5757
only: /(only\s+)?([a-zA-Z]+)\s?/,
58-
minw: /\(min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,
59-
maxw: /\(max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/
58+
minw: /\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,
59+
maxw: /\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/
6060
};
6161

6262
//expose media query support flag for external use

test/unit/tests.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ window.onload = function(){
166166
});
167167
});
168168
});
169+
170+
test( 'Test spaces around min-width/max-width', function() {
171+
ok( '@media only screen and (min-width: 1px) { }'.match( respond.regex.maxw ) === null );
172+
ok( '@media only screen and ( min-width: 1px ) { }'.match( respond.regex.maxw ) === null );
173+
ok( '@media only screen and (min-width: 1px) { }'.match( respond.regex.minw ).length );
174+
ok( '@media only screen and ( min-width: 1px ) { }'.match( respond.regex.minw ).length );
175+
176+
ok( '@media only screen and (max-width: 1280px) { }'.match( respond.regex.minw ) === null );
177+
ok( '@media only screen and ( max-width: 1280px ) { }'.match( respond.regex.minw ) === null );
178+
ok( '@media only screen and (max-width: 1280px) { }'.match( respond.regex.maxw ).length );
179+
ok( '@media only screen and ( max-width: 1280px ) { }'.match( respond.regex.maxw ).length );
180+
});
169181
}
170182

171183
};

0 commit comments

Comments
 (0)