Address review comments
This commit is contained in:
parent
b4f87a288a
commit
016f369ba2
|
@ -3,5 +3,3 @@ import initAnswerbox from '../retrospring/features/answerbox/index';
|
|||
|
||||
start();
|
||||
document.addEventListener('turbolinks:load', initAnswerbox);
|
||||
document.addEventListener('turbolinks:load', initAnswerbox);
|
||||
document.addEventListener('turbolinks:load', initAnswerbox);
|
|
@ -2,10 +2,7 @@ import registerEvents from "retrospring/utilities/registerEvents";
|
|||
import {createShareEvent} from "./share";
|
||||
|
||||
export default (): void => {
|
||||
if (!('share' in navigator)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ('share' in navigator) {
|
||||
document.body.classList.add('cap-web-share');
|
||||
const entries: NodeList = document.querySelectorAll('.answerbox:not(.js-initialized)');
|
||||
|
||||
|
@ -18,3 +15,4 @@ export default (): void => {
|
|||
element.classList.add('js-initialized');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import noop from 'retrospring/utilities/noop';
|
||||
|
||||
export function createShareEvent(answerbox: HTMLElement): () => void {
|
||||
return function (): void {
|
||||
navigator.share({
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export default () => void {
|
||||
// do nothing
|
||||
}
|
Loading…
Reference in New Issue