From 525d7875c9c0d32e89e7a7458e204a75bd5b8259 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Fri, 26 Jan 2024 21:52:07 +0800 Subject: [PATCH] Allow arbitrary whitespaces in `supports` queries (#815) --- index.js | 2 +- test/feature.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 6718031a..d2fd7d1d 100644 --- a/index.js +++ b/index.js @@ -893,7 +893,7 @@ var QUERIES = { }, supports: { matches: ['supportType', 'feature'], - regexp: /^(?:(fully|partially) )?supports\s+([\w-]+)$/, + regexp: /^(?:(fully|partially)\s+)?supports\s+([\w-]+)$/, select: function (context, node) { env.loadFeature(browserslist.cache, node.feature) var withPartial = node.supportType !== 'fully' diff --git a/test/feature.test.js b/test/feature.test.js index 4ec15a93..208915d4 100644 --- a/test/feature.test.js +++ b/test/feature.test.js @@ -72,6 +72,12 @@ test('selects browsers by feature, including partial support', () => { 'chrome 82', 'chrome 81' ]) + + equal(browserslist('partially supports rtcpeerconnection'), [ + 'and_chr 81', + 'chrome 82', + 'chrome 81' + ]) }) test('selects browsers by feature, omiting partial support', () => { @@ -85,6 +91,11 @@ test('selects browsers by feature, omiting partial support', () => { 'and_chr 81', 'chrome 82' ]) + + equal(browserslist('fully supports rtcpeerconnection'), [ + 'and_chr 81', + 'chrome 82' + ]) }) test('selects browsers by feature with dashes in its name', () => {