2
0
mirror of https://github.com/tenrok/maska.git synced 2026-06-17 19:21:21 +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", "name": "maska",
"version": "1.0.1", "version": "1.0.2",
"description": "Simple zero-dependency input mask for Vue.js and vanilla JS", "description": "Simple zero-dependency input mask for Vue.js and vanilla JS",
"keywords": [ "keywords": [
"mask", "mask",
+6 -9
View File
@@ -31,14 +31,14 @@ export default class Maska {
el.dataset.mask = this._opts.mask el.dataset.mask = this._opts.mask
} }
this.updateValue(el) this.updateValue(el)
el.addEventListener('input', evt => this.onInput(evt)) el.addEventListener('input', evt => this.updateValue(evt.target))
} }
} }
destroy () { destroy () {
for (let i = 0; i < this._el.length; i++) { for (let i = 0; i < this._el.length; i++) {
const el = findInputElement(this._el[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 delete el.dataset.mask
} }
} }
@@ -47,15 +47,12 @@ export default class Maska {
if (!el.value || !el.dataset.mask) return if (!el.value || !el.dataset.mask) return
const position = el.selectionEnd 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) el.value = mask(el.value, el.dataset.mask, this._opts.tokens)
fixInputSelection(el, position, digit) fixInputSelection(el, position, digit)
el.dispatchEvent(event('input')) if (el.value !== oldValue) {
} el.dispatchEvent(event('input'))
onInput (event) {
if (event.isTrusted) {
this.updateValue(event.target)
} }
} }
} }