diff --git a/src/respond.js b/src/respond.js index b1a3c394..59d339c4 100644 --- a/src/respond.js +++ b/src/respond.js @@ -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 diff --git a/test/unit/tests.js b/test/unit/tests.js index 8234e98b..e7d384f9 100644 --- a/test/unit/tests.js +++ b/test/unit/tests.js @@ -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 ); + }); } }; \ No newline at end of file