Browse Source

Pull request #2086: 无JIRA任务 避免内存泄露

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit '7db095322c42b9d403d612a702c4ccc4ce594a70':
  避免内存泄露
es6
guy 3 years ago
parent
commit
c4048920a9
  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, { BI.BubblesController = BI.inherit(BI.Controller, {
init: function () { init: function () {
this.storeBubbles = {}; this.storeBubbles = {};
this.storePoppers = {};
}, },
/** /**
@ -48,7 +49,10 @@ BI.BubblesController = BI.inherit(BI.Controller, {
el: bubble 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: ({ placement: ({
left: "top-start", left: "top-start",
center: "top", center: "top",
@ -81,6 +85,7 @@ BI.BubblesController = BI.inherit(BI.Controller, {
return this; return this;
} }
this.storeBubbles[name].destroy(); this.storeBubbles[name].destroy();
this.storePoppers[name] && this.storePoppers[name].destroy();
delete this.storeBubbles[name]; delete this.storeBubbles[name];
return this; return this;
}, },
@ -89,7 +94,11 @@ BI.BubblesController = BI.inherit(BI.Controller, {
BI.each(this.storeBubbles, function (name, bubble) { BI.each(this.storeBubbles, function (name, bubble) {
bubble.destroy(); bubble.destroy();
}); });
BI.each(this.storePoppers, function (name, popper) {
popper.destroy();
});
this.storeBubbles = {}; this.storeBubbles = {};
this.storePoppers = {};
return this; return this;
} }
}); });

Loading…
Cancel
Save