diff --git a/index.js b/index.js index 0783e84..c66abe8 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ var RE_MEDIA_QUERY = /^(?:(only|not)?\s*([_a-z][_a-z0-9-]*)|(\([^\)]+\)))(?: RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?\s*$/, RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?\s*$/; -function matchQuery(mediaQuery, values) { +function matchQuery(mediaQuery, values, ignores) { return parseQuery(mediaQuery).some(function (query) { var inverse = query.inverse; @@ -34,8 +34,11 @@ function matchQuery(mediaQuery, values) { var feature = expression.feature, modifier = expression.modifier, expValue = expression.value, - value = values[feature]; + value = values[feature], + ignore = ignores === undefined ? undefined : ignores[feature]; + // Feature in ignore list + if (ignore) { return true; } // Missing or falsy values don't match. if (!value) { return false; } diff --git a/test/unit-tests.js b/test/unit-tests.js index 2483df5..fc51935 100644 --- a/test/unit-tests.js +++ b/test/unit-tests.js @@ -70,6 +70,12 @@ describe('mediaQuery.match()', function () { )).to.be.false; }); + it('Orientation: should return true for an ignore case', function () { + expect(mediaQuery.match( + '(width: 800px) and (orientation: landscape)', {width: 800}, {orientation: '*'} + )).to.be.true; + }); + it('Scan: should return true for a correct match (===)', function () { expect(mediaQuery.match( '(scan: progressive)', {scan: 'progressive'}