Address review comments

This commit is contained in:
Karina Kwiatek 2021-08-10 15:50:17 +02:00
parent b4f87a288a
commit 016f369ba2
4 changed files with 20 additions and 21 deletions

View File

@ -3,5 +3,3 @@ import initAnswerbox from '../retrospring/features/answerbox/index';
start(); start();
document.addEventListener('turbolinks:load', initAnswerbox); document.addEventListener('turbolinks:load', initAnswerbox);
document.addEventListener('turbolinks:load', initAnswerbox);
document.addEventListener('turbolinks:load', initAnswerbox);

View File

@ -2,10 +2,7 @@ import registerEvents from "retrospring/utilities/registerEvents";
import {createShareEvent} from "./share"; import {createShareEvent} from "./share";
export default (): void => { export default (): void => {
if (!('share' in navigator)) { if ('share' in navigator) {
return;
}
document.body.classList.add('cap-web-share'); document.body.classList.add('cap-web-share');
const entries: NodeList = document.querySelectorAll('.answerbox:not(.js-initialized)'); const entries: NodeList = document.querySelectorAll('.answerbox:not(.js-initialized)');
@ -17,4 +14,5 @@ export default (): void => {
element.classList.add('js-initialized'); element.classList.add('js-initialized');
}); });
}
} }

View File

@ -1,11 +1,11 @@
import noop from 'retrospring/utilities/noop';
export function createShareEvent(answerbox: HTMLElement): () => void { export function createShareEvent(answerbox: HTMLElement): () => void {
return function (): void { return function (): void {
navigator.share({ navigator.share({
url: answerbox.querySelector<HTMLAnchorElement>('.answerbox__answer-date > a').href url: answerbox.querySelector<HTMLAnchorElement>('.answerbox__answer-date > a').href
}).then(() => {
// do nothing, prevents exce ption from being thrown
}).catch(() => {
// do nothing, prevents exception from being thrown
}) })
.then(noop)
.catch(noop)
} }
} }

View File

@ -0,0 +1,3 @@
export default () => void {
// do nothing
}