Skip to content

Commit

Permalink
Fixes #179 (including tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 25, 2013
1 parent 5487dff commit 583ee45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/respond.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
urls: /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,
findStyles: /@media *([^\{]+)\{([\S\s]+?)$/,
only: /(only\s+)?([a-zA-Z]+)\s?/,
minw: /\(min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,
maxw: /\(max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/
minw: /\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,
maxw: /\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/
};

//expose media query support flag for external use
Expand Down
12 changes: 12 additions & 0 deletions test/unit/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ window.onload = function(){
});
});
});

test( 'Test spaces around min-width/max-width', function() {
ok( '@media only screen and (min-width: 1px) { }'.match( respond.regex.maxw ) === null );
ok( '@media only screen and ( min-width: 1px ) { }'.match( respond.regex.maxw ) === null );
ok( '@media only screen and (min-width: 1px) { }'.match( respond.regex.minw ).length );
ok( '@media only screen and ( min-width: 1px ) { }'.match( respond.regex.minw ).length );

ok( '@media only screen and (max-width: 1280px) { }'.match( respond.regex.minw ) === null );
ok( '@media only screen and ( max-width: 1280px ) { }'.match( respond.regex.minw ) === null );
ok( '@media only screen and (max-width: 1280px) { }'.match( respond.regex.maxw ).length );
ok( '@media only screen and ( max-width: 1280px ) { }'.match( respond.regex.maxw ).length );
});
}

};

0 comments on commit 583ee45

Please sign in to comment.