From 70457435b9b79da012103123ab83c1273f040d7f Mon Sep 17 00:00:00 2001 From: wlingke Date: Mon, 4 Dec 2017 20:51:47 -0800 Subject: [PATCH] Check `document` is not undefined before requiring `hammerjs` for server-side-rendering. --- dist/react-hammerjs.es.js | 2 +- dist/react-hammerjs.js | 2 +- dist/react-hammerjs.min.js | 2 +- lib/Hammer.js | 2 +- src/Hammer.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/react-hammerjs.es.js b/dist/react-hammerjs.es.js index b25fc96..6c54211 100644 --- a/dist/react-hammerjs.es.js +++ b/dist/react-hammerjs.es.js @@ -11,7 +11,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" // require('hammerjs') when in a browser. This is safe because Hammer is only // invoked in componentDidMount, which is not executed on the server. -var Hammer = typeof window !== 'undefined' ? require('hammerjs') : undefined; +var Hammer = typeof window !== 'undefined' && typeof document !== 'undefined' ? require('hammerjs') : undefined; var privateProps = { children: true, diff --git a/dist/react-hammerjs.js b/dist/react-hammerjs.js index 4b6127d..8d6f52f 100644 --- a/dist/react-hammerjs.js +++ b/dist/react-hammerjs.js @@ -17,7 +17,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" // require('hammerjs') when in a browser. This is safe because Hammer is only // invoked in componentDidMount, which is not executed on the server. -var Hammer = typeof window !== 'undefined' ? require('hammerjs') : undefined; +var Hammer = typeof window !== 'undefined' && typeof document !== 'undefined' ? require('hammerjs') : undefined; var privateProps = { children: true, diff --git a/dist/react-hammerjs.min.js b/dist/react-hammerjs.min.js index 2c15426..4a64193 100644 --- a/dist/react-hammerjs.min.js +++ b/dist/react-hammerjs.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("prop-types"),require("react")):"function"==typeof define&&define.amd?define(["prop-types","react"],t):e.Hammer=t(e.PropTypes,e.React)}(this,function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){t.hasOwnProperty("vertical")&&console.warn("vertical is deprecated, please use `direction` instead");var n=t.direction;if(n||t.hasOwnProperty("vertical")){var o=n||(t.vertical?"DIRECTION_ALL":"DIRECTION_HORIZONTAL");e.get("pan").set({direction:c[o]}),e.get("swipe").set({direction:c[o]})}t.options&&Object.keys(t.options).forEach(function(n){if("recognizers"===n)Object.keys(t.options.recognizers).forEach(function(n){var o=e.get(n);o.set(t.options.recognizers[n]),t.options.recognizers[n].requireFailure&&o.requireFailure(t.options.recognizers[n].requireFailure)},this);else{var o={};o[n]=t.options[n],e.set(o)}},this),t.recognizeWith&&Object.keys(t.recognizeWith).forEach(function(n){e.get(n).recognizeWith(t.recognizeWith[n])},this),Object.keys(t).forEach(function(n){var o=p[n];o&&(e.off(o),e.on(o,t[n]))})}e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;var a=function(){function e(e,t){for(var n=0;n