Add null-check when updating or destroying an instance.
Throw an error when an instance is not found.
This commit is contained in:
parent
1f082a2e04
commit
f9f20eeb6f
@ -10,6 +10,10 @@ var d = require('../lib/dom')
|
|||||||
module.exports = function (element) {
|
module.exports = function (element) {
|
||||||
var i = instances.get(element);
|
var i = instances.get(element);
|
||||||
|
|
||||||
|
if (!i) {
|
||||||
|
throw new Error('perfect-scrollbar: instance not found');
|
||||||
|
}
|
||||||
|
|
||||||
i.event.unbindAll();
|
i.event.unbindAll();
|
||||||
d.remove(i.scrollbarX);
|
d.remove(i.scrollbarX);
|
||||||
d.remove(i.scrollbarY);
|
d.remove(i.scrollbarY);
|
||||||
|
@ -11,6 +11,10 @@ var d = require('../lib/dom')
|
|||||||
module.exports = function (element) {
|
module.exports = function (element) {
|
||||||
var i = instances.get(element);
|
var i = instances.get(element);
|
||||||
|
|
||||||
|
if (!i) {
|
||||||
|
throw new Error('perfect-scrollbar: instance not found');
|
||||||
|
}
|
||||||
|
|
||||||
// Recalcuate negative scrollLeft adjustment
|
// Recalcuate negative scrollLeft adjustment
|
||||||
i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
|
i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user