futurepress / epub.js

Enhanced eBooks in the browser.
http://futurepress.org
Other
6.43k stars 1.1k forks source link

remove iframe not work correctly #554

Open gimox opened 7 years ago

gimox commented 7 years ago

Sometime loading multiple book can generate error because iframe is not correctly removed.

EPUBJS.Renderer.prototype.remove = function() {
    if(this.render.window) {
        this.render.unload();
        this.render.window.removeEventListener("resize", this.resized);
        this.removeEventListeners();
        this.removeSelectionListeners();
    }

    // clean container content 
    this.container.innerHtml = "";
//  this.container.removeChild(this.element);
};

the issue is on cleaning container instead of remove it.

My proposal is for re-add/uncomment removeChild that is always safe.

EPUBJS.Renderer.prototype.remove = function() {
    if(this.render.window) {
        this.render.unload();
        this.render.window.removeEventListener("resize", this.resized);
        this.removeEventListeners();
        this.removeSelectionListeners();
    }

    // clean container content 
    //this.container.innerHtml = "";
    this.container.removeChild(this.element);
};
fchasen commented 7 years ago

That sounds like a good solution, not sure why the innerHtml ended up there.

A PR with that change would be very appreciated.