Skip to content

Commit

Permalink
amp-ad | refactor fallback 'ad' text in order to easily support i18n (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
tompere authored and lannka committed Jul 14, 2017
1 parent 1b68f43 commit c2a04d7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions 3p/3p.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ function validateAllowedFields(data, allowedFields) {
mode: true,
consentNotificationId: true,
ampSlotIndex: true,
adHolderText: true,
};

for (const field in data) {
Expand Down
2 changes: 2 additions & 0 deletions extensions/amp-ad/0.1/amp-ad-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export class AmpAdUIHandler {
if (isExperimentOn(this.baseInstance_.win, 'ad-loader-v2')) {
content.setAttribute('experiment2', '');
}
// TODO(aghassemi, #4146) i18n
content.setAttribute('data-ad-holder-text', 'Ad');
uiComponent.appendChild(content);

this.baseInstance_.element.appendChild(uiComponent);
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-ad/0.1/amp-ad.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ amp-embed iframe {

.i-amphtml-ad-default-holder:after {
content: "Ad";
content: attr(data-ad-holder-text);
background-color: rgba(0, 0, 0, 0.5);
border-radius: 2px;
color: #fff;
Expand Down
5 changes: 4 additions & 1 deletion extensions/amp-ad/0.1/test/test-amp-ad-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ describes.realWin('amp-ad-ui handler', {
sandbox.stub(adImpl, 'toggleFallback', () => {});
uiHandler.applyNoContentUI();
return promise.then(() => {
expect(adImpl.element.querySelector('[fallback]')).to.be.ok;
const el = adImpl.element.querySelector('[fallback]');
expect(el).to.be.ok;
expect(el.children[0]).to.have.class('i-amphtml-ad-default-holder');
expect(el.children[0]).to.have.attribute('data-ad-holder-text');
});
});

Expand Down

0 comments on commit c2a04d7

Please sign in to comment.