Skip to content

Commit

Permalink
fix(Template): harden Symbol checks (#2749)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Chris DeLuca authored and bobylito committed Feb 26, 2018
1 parent 8dd0b18 commit fab66bc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ function checkRendering(rendering, usage) {
}

const REACT_ELEMENT_TYPE =
(typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) ||
(typeof Symbol === 'function' &&
typeof Symbol.iterator === 'symbol' &&
Symbol.for &&
Symbol.for('react.element')) ||
0xeac7;

function isReactElement(object) {
Expand Down

0 comments on commit fab66bc

Please sign in to comment.