Address review comments
This commit is contained in:
parent
b4f87a288a
commit
016f369ba2
|
@ -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);
|
|
|
@ -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');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
export default () => void {
|
||||||
|
// do nothing
|
||||||
|
}
|
Loading…
Reference in New Issue