Skip to content

Instantly share code, notes, and snippets.

@jonasraoni
jonasraoni / vue-numeric-directive.js
Last active February 22, 2023 10:16
Numeric directive for Vue (v-decimal and v-integer, with an "unsigned" modifier). Useful to improve existing components which you can't modify.
//+ Jonas Raoni Soares Silva
//@ http://raoni.org
export default class NumericDirective {
constructor(input, binding) {
Object.assign(this, {
input,
binding
});
input.addEventListener('keydown', this);