houdini/app/javascript/legacy/common/on-change-sanitize-slug.js

12 lines
420 B
JavaScript
Raw Permalink Normal View History

2019-11-06 20:36:28 +00:00
// 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 )