Retrospring/app/javascript/retrospring/features/answerbox/share.ts

13 lines
364 B
TypeScript
Raw Normal View History

import noop from 'utilities/noop';
2021-08-10 06:50:17 -07:00
export function shareEventHandler(event: Event): void {
event.preventDefault();
const answerbox = (event.target as HTMLElement).closest('.answerbox');
navigator.share({
url: answerbox.querySelector<HTMLAnchorElement>('.answerbox__answer-date > a, a.answerbox__permalink').href
})
2021-08-10 06:50:17 -07:00
.then(noop)
.catch(noop)
2021-08-10 04:16:40 -07:00
}