Skip to content

Commit

Permalink
MWPW-135656: refactor region selector and social links decoration (#1560
Browse files Browse the repository at this point in the history
)

* trivial: Update LICENSE (#1558)

* refactor: decorate links logic

* hotfix

* improved decorate content logic on global-footer

---------

Co-authored-by: Chris Millar <cmillar@adobe.com>
Co-authored-by: Blaine Gunn <Blainegunn@gmail.com>
  • Loading branch information
3 people authored Dec 4, 2023
1 parent 33150d4 commit c9b5d6c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions libs/blocks/global-footer/global-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,15 @@ class Footer {

if (!this.body) return;

// TODO: revisit region picker and social links decoration logic
const regionAnchor = this.body.querySelector('.region-selector a');
if (regionAnchor?.href) {
regionAnchor.setAttribute('href', `${regionAnchor.getAttribute('href')}#_dnt#_dnb`);
}
const socialLinks = document.querySelectorAll('.social a');
socialLinks.forEach((socialLink) => {
socialLink.setAttribute('href', `${socialLink.getAttribute('href')}#_dnb`);
});
const [region, social] = ['.region-selector', '.social'].map((selector) => this.body.querySelector(selector));
const [regionParent, socialParent] = [region.parentElement, social.parentElement];
[regionParent, socialParent].forEach((parent) => parent.replaceChildren());

decorateLinks(this.body);

regionParent.appendChild(region);
socialParent.appendChild(social);

// Order is important, decorateFooter makes use of elements
// which have already been created in previous steps
const tasks = [
Expand Down

0 comments on commit c9b5d6c

Please sign in to comment.