From b01867a819fb2965795226bfcff813ff5f1797fc Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 30 Jan 2019 13:57:07 +0100 Subject: [PATCH] fix(Util): Shim Element in non-DOM environments This change shims the Element object in non-DOM environments to prevent these environments from throwing errors when using `DOMElement` from `util.js`, since it uses Element as right hand side in an `instanceof` check, which fails for undefined values. --- src/utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils.js b/src/utils.js index 209ab4f9b..c1c8effb1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -113,6 +113,9 @@ export function deprecated(propType, explanation) { }; } +// Shim Element if needed (e.g. in Node environment) +const Element = typeof window === 'object' && window.Element || function() {}; + export function DOMElement(props, propName, componentName) { if (!(props[propName] instanceof Element)) { return new Error(