mirror of
https://github.com/tenrok/maska.git
synced 2026-06-23 20:40:35 +03:00
fix: change event abort to manual event removing
Because happy-dom can't handle event abortion and test do not passing
This commit is contained in:
+4
-6
@@ -18,7 +18,6 @@ export interface MaskaDetail {
|
|||||||
|
|
||||||
export class MaskInput {
|
export class MaskInput {
|
||||||
readonly items = new Map<HTMLInputElement, Mask>()
|
readonly items = new Map<HTMLInputElement, Mask>()
|
||||||
private readonly abort = new AbortController()
|
|
||||||
|
|
||||||
constructor (target: MaskaTarget, private options: MaskInputOptions = {}) {
|
constructor (target: MaskaTarget, private options: MaskInputOptions = {}) {
|
||||||
this.init(this.getInputs(target))
|
this.init(this.getInputs(target))
|
||||||
@@ -38,7 +37,9 @@ export class MaskInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy (): void {
|
destroy (): void {
|
||||||
this.abort.abort()
|
for (const input of this.items.keys()) {
|
||||||
|
input.removeEventListener('input', this.onInput)
|
||||||
|
}
|
||||||
this.items.clear()
|
this.items.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,10 +48,7 @@ export class MaskInput {
|
|||||||
|
|
||||||
for (const input of inputs) {
|
for (const input of inputs) {
|
||||||
if (!this.items.has(input)) {
|
if (!this.items.has(input)) {
|
||||||
input.addEventListener('input', this.onInput, {
|
input.addEventListener('input', this.onInput, { capture: true })
|
||||||
signal: this.abort.signal,
|
|
||||||
capture: true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mask = new Mask(parseInput(input, defaults))
|
const mask = new Mask(parseInput(input, defaults))
|
||||||
|
|||||||
Reference in New Issue
Block a user