How to use the @material/textfield/character-counter.MDCTextFieldCharacterCounter.attachTo function in @material/textfield

To help you get started, we’ve selected a few @material/textfield examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matsp / material-components-vue / components / text-field / TextFieldCharacterCounter.vue View on Github external
mounted () {
    const input = this.$el.parentElement.previousElementSibling.querySelector('.mdc-text-field__input')
    if (input instanceof HTMLInputElement) {
      if (this.currentLength === 0) this.cl = input.value.length
      if (this.maxLength === 0) this.ml = input.getAttribute('maxlength')
    }
    if (!(this.getCharacterCounter instanceof Function)) { // can not be init by parent
      this.mdcTextFieldCharacterCounter = MDCTextFieldCharacterCounter.attachTo(this.$el)
      this.mdcTextFieldCharacterCounter.foundation.setCounterValue(this.cl, this.ml)
    }
  },
  methods: {