Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
fix(core/caniuse): set default browsers (speced#4289)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi authored Oct 11, 2022
1 parent 46f7625 commit 1c973c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/core/caniuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ function handleError(err, options, featureURL) {
* @param {Object} conf configuration settings
*/
function normalizeCaniuseConf(conf) {
const DEFAULTS = { removeOnSave: true, browsers: [] };
const defaultBrowsers = new Set(BROWSERS.keys());
defaultBrowsers.delete("op_mob");
defaultBrowsers.delete("opera");
const DEFAULTS = { removeOnSave: true, browsers: [...defaultBrowsers] };
if (typeof conf.caniuse === "string") {
conf.caniuse = { feature: conf.caniuse, ...DEFAULTS };
return;
Expand Down
6 changes: 5 additions & 1 deletion tests/spec/core/caniuse-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ describe("Core — Can I Use", () => {
apiURL,
},
});
const defaultBrowsers = new Set(BROWSERS.keys());
defaultBrowsers.delete("op_mob");
defaultBrowsers.delete("opera");

const doc = await makeRSDoc(ops);
const { caniuse } = doc.defaultView.respecConfig;

expect(caniuse.feature).toBe("FEATURE");
expect(caniuse.browsers).toEqual([]);
expect(caniuse.browsers).toEqual([...defaultBrowsers]);
});

it("allows overriding defaults", async () => {
Expand Down

0 comments on commit 1c973c0

Please sign in to comment.