2
0
mirror of https://github.com/tenrok/maska.git synced 2026-05-15 11:59:38 +03:00

Better autofill handle on iOS

This commit is contained in:
Alexander Shabunevich
2019-09-27 22:15:22 +03:00
parent 80b25a0ce7
commit 9f4b9aecbd
3 changed files with 8 additions and 11 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "maska",
"version": "1.0.1",
"version": "1.0.2",
"description": "Simple zero-dependency input mask for Vue.js and vanilla JS",
"keywords": [
"mask",
+6 -9
View File
@@ -31,14 +31,14 @@ export default class Maska {
el.dataset.mask = this._opts.mask
}
this.updateValue(el)
el.addEventListener('input', evt => this.onInput(evt))
el.addEventListener('input', evt => this.updateValue(evt.target))
}
}
destroy () {
for (let i = 0; i < this._el.length; i++) {
const el = findInputElement(this._el[i])
el.removeEventListener('input', evt => this.onInput(evt))
el.removeEventListener('input', evt => this.updateValue(evt.target))
delete el.dataset.mask
}
}
@@ -47,15 +47,12 @@ export default class Maska {
if (!el.value || !el.dataset.mask) return
const position = el.selectionEnd
const digit = el.value[position - 1]
const oldValue = el.value
const digit = oldValue[position - 1]
el.value = mask(el.value, el.dataset.mask, this._opts.tokens)
fixInputSelection(el, position, digit)
el.dispatchEvent(event('input'))
}
onInput (event) {
if (event.isTrusted) {
this.updateValue(event.target)
if (el.value !== oldValue) {
el.dispatchEvent(event('input'))
}
}
}