<commit_before>/**
 * Copyright (c) 2016 <NAME> <<EMAIL>>
 *
 * This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the GNU Affero General Public License,
 * version 3, as published by the Free Software Foundation.
 */

import { defer } from '../dom/next-render.js'

export class AutoTextarea extends window.HTMLTextAreaElement {
  constructor () {
    super()

    this._resize = this._resize.bind(this)
    this._validate = this._validate.bind(this)

    defer(() => this._resize())
  }

  connectedCallback () {
    this.addEventListener('input', this._resize)
    this.addEventListener('input', this._validate)
  }

  disconnectedCallback () {
    this.removeEventListener('input', this._resize)
    this.removeEventListener('input', this._validate)
  }

  _resize () {
    this.style.height = 'auto'
    this.style.height = `${this.scrollHeight}px`<commit_msg>Fix computation of height in <auto-textarea><commit_after>/**
 * Copyright (c) 2016 <NAME> <<EMAIL>>
 *
 * This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the GNU Affero General Public License,
 * version 3, as published by the Free Software Foundation.
 */

import { defer } from '../dom/next-render.js'

export class AutoTextarea extends window.HTMLTextAreaElement {
  constructor () {
    super()

    this._resize = this._resize.bind(this)
    this._validate = this._validate.bind(this)

    defer(() => this._resize())
  }

  connectedCallback () {
    this.addEventListener('input', this._resize)
    this.addEventListener('input', this._validate)
  }

  disconnectedCallback () {
    this.removeEventListener('input', this._resize)
    this.removeEventListener('input', this._validate)
  }

  _resize () {
    requestAnimationFrame(() => {
      this.style.height = '0'
      this.style.height = `${this.scrollHeight}px`
    })
{'fraction_non_alphanumeric': 0.12395884370406664, 'fraction_numerical': 0.005389514943655071, 'mean_word_length': 3.6727688787185353, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 13, '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': '4139043', 'n_tokens_mistral': 583, 'n_tokens_neox': 559, 'n_words': 167}