Skip to content

Commit

Permalink
Provide unlayoutCallback for amp-izlesene (#33589)
Browse files Browse the repository at this point in the history
* Provide unlayoutCallback for amp-izlesene

* fix spelling
  • Loading branch information
Dima Voytenko authored Apr 1, 2021
1 parent 336e335 commit 0a48ddd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions extensions/amp-izlesene/0.1/amp-izlesene.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ class AmpIzlesene extends AMP.BaseElement {
return this.loadPromise(iframe);
}

/** @override */
unlayoutCallback() {
if (this.iframe_) {
this.element.removeChild(this.iframe_);
this.iframe_ = null;
}
return true;
}

/** @override */
pauseCallback() {
if (this.iframe_ && this.iframe_.contentWindow) {
Expand Down
12 changes: 12 additions & 0 deletions extensions/amp-izlesene/0.1/test/test-amp-izlesene.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,17 @@ describes.realWin(
);
});
});

it('unlayout and relayout', async () => {
const izlesene = await getIzlesene('7221390');
expect(izlesene.querySelector('iframe')).to.exist;

const unlayoutResult = izlesene.unlayoutCallback();
expect(unlayoutResult).to.be.true;
expect(izlesene.querySelector('iframe')).to.not.exist;

await izlesene.layoutCallback();
expect(izlesene.querySelector('iframe')).to.exist;
});
}
);

0 comments on commit 0a48ddd

Please sign in to comment.