From 42a8b45346a548bd93636a5948777aee0b883fe1 Mon Sep 17 00:00:00 2001 From: Ben Lowery Date: Tue, 19 Nov 2019 20:28:55 -0500 Subject: [PATCH] Make global-bind plugin safe in node envs When mousetrap loads in a non-dom environment, it bails early and doesn't set the Mousetrap global. Make the global-bind plugin detect that Mousetrap didn't initialize and bail itself. --- plugins/global-bind/mousetrap-global-bind.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/global-bind/mousetrap-global-bind.js b/plugins/global-bind/mousetrap-global-bind.js index 1c4ac148..c72672a5 100644 --- a/plugins/global-bind/mousetrap-global-bind.js +++ b/plugins/global-bind/mousetrap-global-bind.js @@ -8,6 +8,9 @@ */ /* global Mousetrap:true */ (function(Mousetrap) { + if (! Mousetrap) { + return; + } var _globalCallbacks = {}; var _originalStopCallback = Mousetrap.prototype.stopCallback;