javascript: make utils resilient to missing elements (#4546)
Javascript : les fonctions utilitaires fonctionnent lorsque l'élément n'existe pas
This commit is contained in:
commit
0b8512362e
1 changed files with 6 additions and 6 deletions
|
@ -5,16 +5,16 @@ import debounce from 'debounce';
|
||||||
export { debounce };
|
export { debounce };
|
||||||
export const { fire, ajax } = Rails;
|
export const { fire, ajax } = Rails;
|
||||||
|
|
||||||
export function show({ classList }) {
|
export function show(el) {
|
||||||
classList.remove('hidden');
|
el && el.classList.remove('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hide({ classList }) {
|
export function hide(el) {
|
||||||
classList.add('hidden');
|
el && el.classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toggle({ classList }) {
|
export function toggle(el) {
|
||||||
classList.toggle('hidden');
|
el && el.classList.toggle('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function delegate(eventNames, selector, callback) {
|
export function delegate(eventNames, selector, callback) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue