Skip to content

Commit

Permalink
🐛 amp-access-poool: Ensure main container exists (#26939)
Browse files Browse the repository at this point in the history
* fix(amp-access-poool): ensure container exists

Fixes #26893

* fix(amp-access-poool): upgrade legacy api url

Co-authored-by: Nicolas AUGER <nicolas@poool.fr>
  • Loading branch information
dackmin and NicolasAuger committed Feb 24, 2020
1 parent 090d68f commit 81f3a97
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions extensions/amp-access-poool/0.1/poool-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import {Services} from '../../../src/services';
import {addParamToUrl, addParamsToUrl} from '../../../src/url';
import {dev, userAssert} from '../../../src/log';
import {dev, user, userAssert} from '../../../src/log';
import {dict} from '../../../src/utils/object';
import {getMode} from '../../../src/mode';
import {listenFor} from '../../../src/iframe-helper';
Expand All @@ -24,7 +24,7 @@ import {resetStyles, setStyle, setStyles} from '../../../src/style';
const TAG = 'amp-access-poool';

const ACCESS_CONFIG = {
'authorization': 'https://api.poool.fr/api/v2/amp/access?rid=READER_ID',
'authorization': 'https://api.poool.fr/api/v3/amp/access?rid=READER_ID',
'iframe':
'https://assets.poool.fr/amp.html' +
'?rid=READER_ID' +
Expand Down Expand Up @@ -174,11 +174,23 @@ export class PooolVendor {
});
}

/**
* @return {!Element}
* @private
*/
getContainer_() {
const paywallContainer = this.ampdoc.getElementById('poool');
return user().assertElement(
paywallContainer,
'No element with id #poool found to render paywall into, got'
);
}

/**
* @private
*/
renderPoool_() {
const pooolContainer = this.ampdoc.getElementById('poool');
const pooolContainer = this.getContainer_();
const urlPromise = this.accessSource_.buildUrl(
addParamsToUrl(
this.iframeUrl_,
Expand Down

0 comments on commit 81f3a97

Please sign in to comment.