Skip to content

Commit

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

* fix spelling
Dima Voytenko authored Apr 1, 2021
1 parent 0a48ddd commit fb0460f
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
@@ -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');
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
@@ -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({

0 comments on commit fb0460f

Please sign in to comment.