From 086ada40f12505ec8eab90ca2a901b49347be4ee Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 1 Nov 2021 16:01:05 -0700 Subject: [PATCH] Polyfill Promise.any Resolves Sentry issue IMPRESS-2020-7T --- src/app/components/OutfitPreview.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/app/components/OutfitPreview.js b/src/app/components/OutfitPreview.js index c542219..75c1978 100644 --- a/src/app/components/OutfitPreview.js +++ b/src/app/components/OutfitPreview.js @@ -522,4 +522,21 @@ function FadeInOnLoad({ children, ...props }) { ); } +// Polyfill Promise.any for older browsers: https://github.com/ungap/promise-any +// NOTE: Normally I would've considered Promise.any within our support browser +// rangeā€¦ but it's affected 25 users in the past two months, which is +// surprisingly high. And the polyfill is small, so let's do it! (11/2021) +Promise.any = + Promise.any || + function ($) { + return new Promise(function (D, E, A, L) { + A = []; + L = $.map(function ($, i) { + return Promise.resolve($).then(D, function (O) { + return ((A[i] = O), --L) || E({ errors: A }); + }); + }).length; + }); + }; + export default OutfitPreview;