diff --git a/src/js/plugin/destroy.js b/src/js/plugin/destroy.js index 6c8e33a..67bc2b9 100644 --- a/src/js/plugin/destroy.js +++ b/src/js/plugin/destroy.js @@ -10,6 +10,10 @@ var d = require('../lib/dom') module.exports = function (element) { var i = instances.get(element); + if (!i) { + throw new Error('perfect-scrollbar: instance not found'); + } + i.event.unbindAll(); d.remove(i.scrollbarX); d.remove(i.scrollbarY); diff --git a/src/js/plugin/update.js b/src/js/plugin/update.js index 7585df0..5da6b18 100644 --- a/src/js/plugin/update.js +++ b/src/js/plugin/update.js @@ -11,6 +11,10 @@ var d = require('../lib/dom') module.exports = function (element) { var i = instances.get(element); + if (!i) { + throw new Error('perfect-scrollbar: instance not found'); + } + // Recalcuate negative scrollLeft adjustment i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;