1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2026-08-16 05:54:53 +02:00
Files
cheatsheets/_parcel/behaviors/search-form.js
German Capuano 8a9907db52 fix accessibility and search form (#1501)
Co-authored-by: German Capuano <e@gcapu.com>
Co-authored-by: Rico Sta. Cruz <rstacruz@users.noreply.github.com>
2020-07-12 23:34:53 +10:00

18 lines
373 B
JavaScript

import onmount from 'onmount'
import on from 'dom101/on'
/**
* Submitting the search form
*/
onmount('[data-js-search-form]', function () {
on(this, 'submit', (e) => {
e.preventDefault()
const link = document.querySelector('a[data-search-index]:not([hidden])')
const href = link && link.getAttribute('href')
if (href) window.location = href
})
})