Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x | export function patchAllCanonicalMobileMarkup() {
const allCanonicalMobile = document.getElementById("all-canonical-mobile");
const topMobileSections = allCanonicalMobile?.querySelectorAll(
".global-nav__dropdown-toggle"
);
topMobileSections?.forEach((section: Element) => {
const sectionLink = section.querySelector("button.p-navigation__link");
const sectionHref = sectionLink?.getAttribute("href");
const sectionLinksList = section.querySelector("ul");
sectionLinksList?.setAttribute("aria-hidden", "true");
// add the back button as the first item of the section
Eif (sectionHref && sectionLinksList) {
sectionLinksList.prepend(createBackButtonItem(sectionHref));
}
});
}
function createFromHTML(html: string) {
const div = window.document.createElement("div");
div.innerHTML = html;
return div.childNodes[0];
}
function createBackButtonItem(href: string) {
// remove the # from the href
const ariaControls = href.slice(1);
return createFromHTML(`<li class="p-navigation__item--dropdown-close">
<a href=${href} aria-controls=${ariaControls} class="p-navigation__link js-back-button">
Back
</a>
</li>`);
}
|