Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

issue#9 #10

Merged
merged 1 commit into from
Nov 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ Iframe.prototype.remove = function() {
Iframe.prototype.resize = function(w, h) {
if (w) { this.width = w; }
if (h) { this.height = h; }
this.element.style.width = validSize(this.width);
this.element.style.height = validSize(this.height);

if (this.element && this.element.style) {
this.element.style.width = validSize(this.width);
this.element.style.height = validSize(this.height);
}

return this;
};

Expand Down
11 changes: 11 additions & 0 deletions test/iframe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,15 @@ describe('iframe', function () {
expect(iframe.element.style.width).to.equal('250px');
expect(iframe.element.style.height).to.equal('200px');
});

it('should not throw an error when resizing if element was removed', function() {
var iframe = new Iframe('resize-test', {width:100, height:100, iframeUrl:'about:blank'});
var fakeParent = document.createElement('div');

iframe.makeIframe();
fakeParent.appendChild(iframe.wrapper);
iframe.remove();
expect(iframe.resize).to.not.throw(Error);
});

});