Browse Source

避免内存泄露

es6
guy 3 years ago
parent
commit
7db095322c
  1. 11
      src/core/controller/controller.bubbles.js

11
src/core/controller/controller.bubbles.js

@ -8,6 +8,7 @@
BI.BubblesController = BI.inherit(BI.Controller, {
init: function () {
this.storeBubbles = {};
this.storePoppers = {};
},
/**
@ -48,7 +49,10 @@ BI.BubblesController = BI.inherit(BI.Controller, {
el: bubble
}]
});
BI.Popper.createPopper(context.element[0], bubble.element[0], {
if (this.storePoppers[name]) {
this.storePoppers[name].destroy();
}
this.storePoppers[name] = BI.Popper.createPopper(context.element[0], bubble.element[0], {
placement: ({
left: "top-start",
center: "top",
@ -81,6 +85,7 @@ BI.BubblesController = BI.inherit(BI.Controller, {
return this;
}
this.storeBubbles[name].destroy();
this.storePoppers[name] && this.storePoppers[name].destroy();
delete this.storeBubbles[name];
return this;
},
@ -89,7 +94,11 @@ BI.BubblesController = BI.inherit(BI.Controller, {
BI.each(this.storeBubbles, function (name, bubble) {
bubble.destroy();
});
BI.each(this.storePoppers, function (name, popper) {
popper.destroy();
});
this.storeBubbles = {};
this.storePoppers = {};
return this;
}
});

Loading…
Cancel
Save