Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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; }

Expand Down
6 changes: 6 additions & 0 deletions test/unit-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
Expand Down