Skip to content

Commit fab66bc

Browse files
Chris DeLucabobylito
authored andcommitted
fix(Template): harden Symbol checks (#2749)
If a `Symbol` polyfill is present, the instantsearch script presumes that `Symbol` is fully implemented. However, `Symbol` polyfills cannot replicate the behavior fully. This causes the instantsearch script to error out and cause problems on the page if a `Symbol` polyfill is used. This commit hardens the `Symbol` checks to make sure real `Symbol`s are supported, not just a polyfill. NOTE: The google maps API library is a common library that implements a `Symbol` polyfill. @see: * https://stackoverflow.com/questions/48532850/is-google-maps-js-library-polyfilling-symbol * https://stackoverflow.com/questions/39803281/get-typeof-of-the-value-in-es6#39805240
1 parent 8dd0b18 commit fab66bc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,10 @@ function checkRendering(rendering, usage) {
367367
}
368368

369369
const REACT_ELEMENT_TYPE =
370-
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) ||
370+
(typeof Symbol === 'function' &&
371+
typeof Symbol.iterator === 'symbol' &&
372+
Symbol.for &&
373+
Symbol.for('react.element')) ||
371374
0xeac7;
372375

373376
function isReactElement(object) {

0 commit comments

Comments
 (0)