Changing the approach to how this directive is implemented may make it work better with custom input components.
Rather than reply on the v-model (and firing input events, which may not always be the event used in a custom component), binding to the elements native input event, grabbing the current value via evt.target.value and formatting it, then setting the value via evt.target.valuemight make this directive more robust.
One can check if they are on a custom component by checking if el has the el.__vue__ property, and if so, then trigger the 'vue' input event el.__vue__.$emit('input', evt.target.value).
Adding a modifier to the direction to set which event is fired would be good as well (i.e. input or change)
Changing the approach to how this directive is implemented may make it work better with custom input components.
Rather than reply on the
v-model(and firinginputevents, which may not always be the event used in a custom component), binding to the elements nativeinputevent, grabbing the current value viaevt.target.valueand formatting it, then setting the value viaevt.target.valuemight make this directive more robust.One can check if they are on a custom component by checking if
elhas theel.__vue__property, and if so, then trigger the 'vue'inputeventel.__vue__.$emit('input', evt.target.value).Adding a modifier to the direction to set which event is fired would be good as well (i.e.
inputorchange)