add jsdoc comments
This commit is contained in:
1 parent
6de354ad47
commit
8c1205bc13
24 files changed
+1228
-425
No files matched your search
+17
-5
@@ -1,16 +1,28 @@
|
||||
/**
|
||||
* @param {HTMLElement} element
|
||||
* @param {RegExp} regex
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
export function validation(element, regex) {
|
||||
if (element instanceof HTMLElement && regex instanceof RegExp) {
|
||||
element.addEventListener('change', e => {
|
||||
if (regex.test(e.target.value)) {
|
||||
e.target.classList.remove('validation-error');
|
||||
} else {
|
||||
e.target.classList.add('validation-error');
|
||||
const target = e.target;
|
||||
if (target instanceof HTMLElement) {
|
||||
if (regex.test(/** @type {HTMLInputElement} */(target).value)) {
|
||||
target.classList.remove('validation-error');
|
||||
} else {
|
||||
target.classList.add('validation-error');
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{[key: string]: string}} style
|
||||
* @returns {string}
|
||||
*/
|
||||
export function convertCssStyle(style) {
|
||||
return Object.entries(style).map(s => `${s[0]}: ${s[1]}`).join('; ');
|
||||
return Object.entries(style).map(([key, value]) => `${key}: ${value}`).join('; ');
|
||||
}
|
||||
Reference in new issue
Block a user