diff --git a/src/directive.ts b/src/directive.ts index fc942bc..56198a2 100644 --- a/src/directive.ts +++ b/src/directive.ts @@ -6,14 +6,14 @@ type MaskaDirective = Directive const masks = new WeakMap() // hacky way to update binding.arg without using defineExposed -const setArg = (binding: DirectiveBinding, value: string | boolean) => { - if (!binding.arg || (binding.instance == null)) return +const setArg = (binding: DirectiveBinding, value: string | boolean): void => { + if (binding.arg == null || (binding.instance == null)) return const inst = binding.instance as any if (binding.arg in inst) { inst[binding.arg] = value // options api - } else if (inst.$?.setupState && binding.arg in inst.$.setupState) { + } else if (inst.$?.setupState != null && binding.arg in inst.$.setupState) { inst.$.setupState[binding.arg] = value // composition api } } @@ -24,8 +24,8 @@ export const vMaska: MaskaDirective = (el, binding) => { if (input == null || input?.type === 'file') return - if (binding.arg) { - const updateArg = (detail: MaskaDetail) => { + if (binding.arg != null) { + const updateArg = (detail: MaskaDetail): void => { const value = binding.modifiers.unmasked ? detail.unmasked : binding.modifiers.completed diff --git a/src/mask-input.ts b/src/mask-input.ts index 21c25ad..4bf1be5 100644 --- a/src/mask-input.ts +++ b/src/mask-input.ts @@ -31,8 +31,8 @@ export class MaskInput { this.init(Array.from(this.items.keys()), needUpdate) } - updateValue (input: HTMLInputElement) { - if (input.value && input.value !== this.processInput(input).masked) { + updateValue (input: HTMLInputElement): void { + if (input.value !== '' && input.value !== this.processInput(input).masked) { this.setValue(input, input.value) } } @@ -97,7 +97,7 @@ export class MaskInput { this.fixCursor(input, isDelete, () => this.setValue(input, value)) } - private fixCursor (input: HTMLInputElement, isDelete: boolean, closure: any) { + private fixCursor (input: HTMLInputElement, isDelete: boolean, closure: CallableFunction): void { const pos = input.selectionStart const value = input.value