houdini/app/javascript/legacy/common/on-change-sanitize-slug.js
2020-04-23 14:09:14 -05:00

11 lines
420 B
JavaScript

// License: LGPL-3.0-or-later
const R = require('ramda')
const sanitize = require('./sanitize-slug')
// Just a hacky way to automatically sanitize slug inputs when they are changed
var inputs = document.querySelectorAll('.js-sanitizeSlug')
R.map(
inp => inp.addEventListener('change', ev => ev.currentTarget.value = sanitize(ev.currentTarget.value || ev.currentTarget.getAttribute('data-slug-default')))
, inputs )