From 441619b5e8b43250c6dc73a912ef2e0f851fc785 Mon Sep 17 00:00:00 2001 From: Nathan Gelman Date: Thu, 18 Jul 2019 18:36:07 -0700 Subject: [PATCH] fix(Carousel): ie11 compatibility changes(#799) This applies the CustomEvent polyfill recommended in the MDN web docs (https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill). This also applies a simple polyfill for Object.values I found in the react-transition-group module (https://github.com/reactjs/react-transition-group/blob/9e3b2d3c09b78e755bdc837b7b38337812ede2c9/src/TransitionGroup.js#L11). Fixes #799 --- src/index.js | 1 + src/polyfill.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/polyfill.js diff --git a/src/index.js b/src/index.js index b089eedee..f32b5a445 100644 --- a/src/index.js +++ b/src/index.js @@ -85,3 +85,4 @@ export UncontrolledDropdown from './UncontrolledDropdown'; export UncontrolledTooltip from './UncontrolledTooltip'; export Spinner from './Spinner'; export * as Util from './utils'; +export * as Polyfill from './polyfill' diff --git a/src/polyfill.js b/src/polyfill.js new file mode 100644 index 000000000..3c08c3e3e --- /dev/null +++ b/src/polyfill.js @@ -0,0 +1,20 @@ +(() => { + if ( typeof window.CustomEvent === 'function' ) return; + + const CustomEvent = (( event, params ) => { + params = params || { bubbles: false, cancelable: false, detail: null }; + var evt = document.createEvent( 'CustomEvent' ); + evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); + return evt; + }); + + window.CustomEvent = CustomEvent; +})(); + +(() => { + if ( typeof Object.values === 'function' ) return; + + const values = ( (O) => Object.keys(O).map((key) => O[key]) ); + + Object.values = values; +})();