Skip to content

Commit

Permalink
Provide unlayoutCallback for amp-kaltura-player (ampproject#33590)
Browse files Browse the repository at this point in the history
* Provide unlayoutCallback for amp-kaltura-player

* fix spelling
  • Loading branch information
Dima Voytenko authored and rochapablo committed Aug 30, 2021
1 parent b5c79c0 commit a41a4f2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions extensions/amp-kaltura-player/0.1/amp-kaltura-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ class AmpKaltura extends AMP.BaseElement {
return this.loadPromise(iframe);
}

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

/** @override */
createPlaceholderCallback() {
const placeholder = this.win.document.createElement('amp-img');
Expand Down
17 changes: 17 additions & 0 deletions extensions/amp-kaltura-player/0.1/test/test-amp-kaltura-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ describes.realWin(
});
});

it('unlayout and relayout', async () => {
const kp = await getKaltura({
'data-partner': '1281471',
'data-entryid': '1_3ts1ms9c',
'data-uiconf': '33502051',
'data-param-my-param': 'hello world',
});
expect(kp.querySelector('iframe')).to.exist;

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

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

describe('createPlaceholderCallback', () => {
it('should create a placeholder image', () => {
return getKaltura({
Expand Down

0 comments on commit a41a4f2

Please sign in to comment.