<commit_before>{defer, findClosestElementFromNode, normalizeSpaces, summarizeStringChange} = Trix

class Trix.MutationObserver extends Trix.BasicObject
  mutableSelector = "[data-trix-mutable]"

  options =
    attributes: true
    childList: true
    characterData: true
    characterDataOldValue: true
    subtree: true

  constructor: (@element) ->
    @observer = new window.MutationObserver @didMutate
    @start()

  start: ->
    @reset()
    @observer.observe(@element, options)

  stop: ->
    @observer.disconnect()

  didMutate: (mutations) =>
    clearTimeout(@debounce)
    @mutations.push(@findSignificantMutations(mutations)...)

    @debounce = setTimeout =>
      if @mutations.length
        @delegate?.elementDidMutate?(@getMutationSummary())
        @reset()
    , 1
<commit_msg>Remove timeout to ensure mutations are dispatched in order after composition events<commit_after>{defer, findClosestElementFromNode, normalizeSpaces, summarizeStringChange} = Trix

class Trix.MutationObserver extends Trix.BasicObject
  mutableSelector = "[data-trix-mutable]"

  options =
    attributes: true
    childList: true
    characterData: true
    characterDataOldValue: true
    subtree: true

  constructor: (@element) ->
    @observer = new window.MutationObserver @didMutate
    @start()

  start: ->
    @reset()
    @observer.observe(@element, options)

  stop: ->
    @observer.disconnect()

  didMutate: (mutations) =>
    @mutations.push(@findSignificantMutations(mutations)...)

    if @mutations.length
      @delegate?.elementDidMutate?(@getMutationSummary())
      @reset()

{'fraction_non_alphanumeric': 0.11152882205513784, 'fraction_numerical': 0.0006265664160401002, 'mean_word_length': 3.8837920489296636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '4032129', 'n_tokens_mistral': 494, 'n_tokens_neox': 464, 'n_words': 99}