UNPKG

@miyagi/core

Version:

miyagi is a component development tool for JavaScript template engines.

20 lines (16 loc) 495 B
export default (links) => { if (parent.window) { const linkClass = "Component-file"; links.forEach((link) => { link.addEventListener("click", (e) => { const el = e.target.closest(`.${linkClass}`); history.replaceState(null, null, el.href); // see http://www.webdeveasy.com/back-button-behavior-on-a-page-with-an-iframe/ parent.window.dispatchEvent( new CustomEvent("pageChanged", { detail: encodeURI(el.getAttribute("href")), }), ); }); }); } };