Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [Extension AMP-AD] Implement feature to create a data vars slot id by unit when data-slot is entered #36160

Closed
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2e886ec
feat: Custom style
Apr 27, 2021
cc4eb72
Revert "feat: Custom style"
Apr 27, 2021
8be40e1
feat: Add custom style
Apr 27, 2021
d60b415
Merge branch 'main' of github.com:ampproject/amphtml
Apr 27, 2021
5f791b8
test: Change tests
May 4, 2021
7ad5e53
Merge branch 'main' of github.com:ampproject/amphtml
May 4, 2021
c88c9c2
Merge branch 'feature/custom-style' of github.com:denakop/amphtml
May 4, 2021
b454147
Merge branch 'main' of github.com:ampproject/amphtml
May 5, 2021
386df3f
fix: Fix lint issues
May 10, 2021
078f099
Merge branch 'main' of github.com:ampproject/amphtml
May 10, 2021
631b80d
feat: Custom style
Apr 27, 2021
c952db6
Revert "feat: Custom style"
Apr 27, 2021
be7e2b3
feat: Add custom style
Apr 27, 2021
b495939
test: Change tests
May 4, 2021
acc70bb
fix: Fix lint issues
May 10, 2021
5497152
Merge branch 'master' of github.com:denakop/amphtml
May 13, 2021
279828a
Merge branch 'ampproject:main' into master
EdmilsonSilva May 13, 2021
f0ed26c
Merge branch 'main' of github.com:ampproject/amphtml
May 13, 2021
f473d02
Merge branch 'master' of github.com:denakop/amphtml
May 13, 2021
bac3fca
Revert "fix: Fix lint issues"
May 13, 2021
0347f9a
fix: Fix lint issues
May 13, 2021
b37963d
Merge branch 'ampproject:main' into master
EdmilsonSilva May 19, 2021
656acf8
Merge remote-tracking branch 'upstream/main'
kelvinbiffi Sep 4, 2021
fdbb2de
Merge remote-tracking branch 'upstream/main'
kelvinbiffi Sep 10, 2021
188631a
Merge remote-tracking branch 'upstream/main'
kelvinbiffi Sep 15, 2021
e7371b9
Merge branch 'upstreamed/main'
kelvinbiffi Sep 22, 2021
4a8cbfc
amp-ad: Added logic to create a data vars slot id by unit when data-s…
kelvinbiffi Sep 24, 2021
69c103b
Changed counter by unit logic to use less code and changed property n…
kelvinbiffi Sep 24, 2021
172b157
Added changes to logic who create the index by unitId
kelvinbiffi Oct 27, 2021
f2de366
Merge branch 'upstreamed/main' into feature/amp-ad-data-vars-slot-id-…
kelvinbiffi Oct 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions extensions/amp-ad/0.1/amp-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,28 @@ export class AmpAd extends AMP.BaseElement {

this.win.ampAdSlotIdCounter = this.win.ampAdSlotIdCounter || 0;
const slotId = this.win.ampAdSlotIdCounter++;
let slotIdByUnit;

if (this.element.hasAttribute('data-slot')) {
const dataSlot = this.element.getAttribute('data-slot');
this.win.ampAdSlotIdByUnitCounter =
this.win.ampAdSlotIdByUnitCounter || {};
this.win.ampAdSlotIdByUnitCounter[dataSlot] =
this.win.ampAdSlotIdByUnitCounter[dataSlot] || 0;
slotIdByUnit = this.win.ampAdSlotIdByUnitCounter[dataSlot]++;
}
kelvinbiffi marked this conversation as resolved.
Show resolved Hide resolved

return new Promise((resolve) => {
this.getVsync().mutate(() => {
this.element.setAttribute('data-amp-slot-index', slotId);

if (this.element.hasAttribute('data-slot')) {
this.element.setAttribute(
'data-vars-slot-index-by-unit',
slotIdByUnit
kelvinbiffi marked this conversation as resolved.
Show resolved Hide resolved
);
}

const useRemoteHtml = this.element
.getAmpDoc()
.getMetaByName('amp-3p-iframe-src');
Expand Down