mirror of
https://github.com/tenrok/maska.git
synced 2026-06-11 18:02:27 +03:00
Fix #31: mask value on v-model change
This commit is contained in:
+12
-4
@@ -22,10 +22,18 @@ function needUpdate (mask) {
|
||||
)
|
||||
}
|
||||
|
||||
export default function directive (el, mask) {
|
||||
if (!mask.value) return
|
||||
const directive = () => {
|
||||
const state = new WeakMap()
|
||||
|
||||
if (mask.value && needUpdate(mask)) {
|
||||
return new Maska(el, getOpts(mask.value))
|
||||
return (el, mask) => {
|
||||
if (!mask.value) return
|
||||
|
||||
if (state.has(el) && !needUpdate(mask)) {
|
||||
return state.get(el).updateValue(el)
|
||||
}
|
||||
|
||||
state.set(el, new Maska(el, getOpts(mask.value)))
|
||||
}
|
||||
}
|
||||
|
||||
export default directive()
|
||||
|
||||
Reference in New Issue
Block a user