From cb1df97a321cf40cec8be93112edc7b0005538e2 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 12 Nov 2019 18:02:13 +0100 Subject: [PATCH 1/2] test: Add test for literal 0 --- test/unit-tests.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/unit-tests.js b/test/unit-tests.js index 2483df5..5969e0d 100644 --- a/test/unit-tests.js +++ b/test/unit-tests.js @@ -158,6 +158,12 @@ describe('mediaQuery.match()', function () { '(max-height: 1000px)', {height: '60pc'} )).to.be.true; }); + + it('should work with literal 0', function () { + expect(mediaQuery.match( + '(max-height: 1000px)', {height: 0} + )).to.be.true; + }); }); }); From 5094cd140f263dad1f2d48c760e0c9cdcf94b5b0 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 12 Nov 2019 18:02:44 +0100 Subject: [PATCH 2/2] fix: 0 length never matching --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 0783e84..15e8884 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,7 @@ function matchQuery(mediaQuery, values) { value = values[feature]; // Missing or falsy values don't match. - if (!value) { return false; } + if (!value && value !== 0) { return false; } switch (feature) { case 'orientation':