<commit_before>import utils from './utils';

class CreditCardSpace {
  constructor(element) {
    if (!(element instanceof Element)) {
      throw new Error('CreditCardSpace can be attached to an Element only');
    }
    this.element = element;
    attachEvents(element);
  }

  value() {
    return utils.clearFormattedCardNumber(this.element.value);
  }

  destroy() {
    this.element.removeEventListener(inputHandler);
    this.element.removeEventListener(keyDownHandler);
  }
}

function attachEvents(element) {
  element.addEventListener('input', inputHandler);
  element.addEventListener('keydown', keyDownHandler);
}
<commit_msg>fix(input): fix cursor position on android<commit_after>import utils from './utils';

class CreditCardSpace {
  constructor(element) {
    if (!(element instanceof Element)) {
      throw new Error('CreditCardSpace can be attached to an Element only');
    }
    this.element = element;
    attachEvents(element);
  }

  value() {
    return utils.clearFormattedCardNumber(this.element.value);
  }

  destroy() {
    this.element.removeEventListener(inputHandler);
    this.element.removeEventListener(keyDownHandler);
  }
}

function attachEvents(element) {
  element.addEventListener('input', (event) => {
    setTimeout(
      () => inputHandler(event)
    );
  });
  element.addEventListener('keydown', keyDownHandler);
}

{'fraction_non_alphanumeric': 0.1217008797653959, 'fraction_numerical': 0.0, 'mean_word_length': 4.25, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2520596', 'n_tokens_mistral': 378, 'n_tokens_neox': 376, 'n_words': 79}