What's better - to leave the IF
block blank to do nothing, or to add a statement that basically does nothing (each link already has a href
attribute)?
export function fixRelativeLinksOutsideOfEpub(dom): void {
const content = dom.window.document.querySelectorAll('a');
content.forEach((element: HTMLElement) => {
const href = element.getAttribute('href');
if (href.indexOf('#') === 0) {
// do nothing
} else {
element.setAttribute('target', '_blank');
}
});
}
export function fixRelativeLinksOutsideOfEpub(dom): void {
const content = dom.window.document.querySelectorAll('a');
content.forEach((element: HTMLElement) => {
const href = element.getAttribute('href');
if (href.indexOf('#') === 0) {
element.setAttribute('href', `${href}`);
} else {
element.setAttribute('target', '_blank');
}out
});
}