<commit_before>describe('Integration: outerHTML', function() {
  beforeEach(function() {
    this.fixture = document.createElement('div');
    this.fixture.innerHTML = '<div></div>';
  });

  afterEach(function() {
    diff.release(this.fixture);
    diff.removeTransitionState();
  });

  it('can recalculate the tree if contents are unexpectedly changed', function() {
    diff.outerHTML(this.fixture, '<div><p></p></div>');
    this.fixture.innerHTML = '<span></span>';
    diff.outerHTML(this.fixture, '<div><p>this</p></div>');

    assert.equal(this.fixture.firstChild.tagName, 'P');
    assert.equal(this.fixture.firstChild.textContent, 'this');
  });

  it('can replace the documentElement', function() {
    var iframe = document.createElement('iframe');
    document.body.appendChild(iframe);

    var documentElement = iframe.contentDocument.documentElement;
    var originalSource = documentElement.outerHTML;

    diff.outerHTML(documentElement, '<html><head></head></html>');
    assert.equal(documentElement.childNodes.length, 1);

    diff.outerHTML(documentElement, originalSource);
    assert.equal(documentElement.childNodes.length, 2);

    diff.release(documentElement);

    iframe.parentNode.removeChild(iframe);
  });

  it('cannot replace an element without a parent', function() {
    assert.throws(function() {
      diff.outerHTML(this.fixture, '<p></p>');
    });
  });

  it('can replace an element with a parent', function() {
    diff.outerHTML(this.fixture.firstChild, '<p></p>');

    assert.equal(this.fixture.firstChild.tagName, 'P');
  });

  describe('Comments', function() {
    it('ignores comments', function() {
      diff.outerHTML(this.fixture, '<div><p><!-- test --></p></div>');

      assert.equal(this.fixture.innerHTML, '<p></p>');
    });
  });

  describe('Text', function() {
    it('can be updated by directly setting', function() {
      diff.outerHTML(this.fixture, '<div>test</div>');

      assert.equal(this.fixture.textContent, 'test');

      diff.outerHTML(this.fixture, '<div>this</div>');

      assert.equal(this.fixture.textContent, 'this');
    });

    it('can replace over markup', function() {
      diff.outerHTML(this.fixture, '<div><div>test div</div></div>');
      diff.outerHTML(this.fixture, '<div>this</div>');

      assert.equal(this.fixture.innerHTML, 'this');
    });

    it('will not replace a previous span', function() {
      diff.outerHTML(this.fixture, '<div><span class="test"></span></div>');
      var span = this.fixture.querySelector('.test');
      diff.outerHTML(this.fixture, '<div><span>whatever</span></div>');

      assert.equal(this.fixture.innerHTML, '<span>whatever</span>');
      assert.equal(this.fixture.firstChild, span, 'are the same element');
    });

    it('supports html5 entities', function() {
      diff.outerHTML(this.fixture, '<div>&gla;</div>');

      assert.equal(this.fixture.innerHTML, '⪥');
    });
  });

  describe('Attributes', function() {
    it('can change attributes', function() {
      diff.outerHTML(this.fixture, '<div class="hello"></div>');

      assert.equal(this.fixture.className, 'hello');
    });

    it('can change attributes more than once', function() {
      diff.outerHTML(this.fixture, '<div class="hello"></div>');
      diff.outerHTML(this.fixture, '<div class="hello to you"></div>');

      assert.equal(this.fixture.className, 'hello to you');
    });

    it('supports inline styles', function() {
      diff.outerHTML(this.fixture,
        '<div><p style="font-size: 11px"></p></div>');<commit_msg>Test showing issue with empty attributes<commit_after>describe('Integration: outerHTML', function() {
  beforeEach(function() {
    this.fixture = document.createElement('div');
    this.fixture.innerHTML = '<div></div>';
  });

  afterEach(function() {
    diff.release(this.fixture);
    diff.removeTransitionState();
  });

  it('can recalculate the tree if contents are unexpectedly changed', function() {
    diff.outerHTML(this.fixture, '<div><p></p></div>');
    this.fixture.innerHTML = '<span></span>';
    diff.outerHTML(this.fixture, '<div><p>this</p></div>');

    assert.equal(this.fixture.firstChild.tagName, 'P');
    assert.equal(this.fixture.firstChild.textContent, 'this');
  });

  it('can replace the documentElement', function() {
    var iframe = document.createElement('iframe');
    document.body.appendChild(iframe);

    var documentElement = iframe.contentDocument.documentElement;
    var originalSource = documentElement.outerHTML;

    diff.outerHTML(documentElement, '<html><head></head></html>');
    assert.equal(documentElement.childNodes.length, 1);

    diff.outerHTML(documentElement, originalSource);
    assert.equal(documentElement.childNodes.length, 2);

    diff.release(documentElement);

    iframe.parentNode.removeChild(iframe);
  });

  it('cannot replace an element without a parent', function() {
    assert.throws(function() {
      diff.outerHTML(this.fixture, '<p></p>');
    });
  });

  it('can replace an element with a parent', function() {
    diff.outerHTML(this.fixture.firstChild, '<p></p>');

    assert.equal(this.fixture.firstChild.tagName, 'P');
  });

  describe('Comments', function() {
    it('ignores comments', function() {
      diff.outerHTML(this.fixture, '<div><p><!-- test --></p></div>');

      assert.equal(this.fixture.innerHTML, '<p></p>');
    });
  });

  describe('Text', function() {
    it('can be updated by directly setting', function() {
      diff.outerHTML(this.fixture, '<div>test</div>');

      assert.equal(this.fixture.textContent, 'test');

      diff.outerHTML(this.fixture, '<div>this</div>');

      assert.equal(this.fixture.textContent, 'this');
    });

    it('can replace over markup', function() {
      diff.outerHTML(this.fixture, '<div><div>test div</div></div>');
      diff.outerHTML(this.fixture, '<div>this</div>');

      assert.equal(this.fixture.innerHTML, 'this');
    });

    it('will not replace a previous span', function() {
      diff.outerHTML(this.fixture, '<div><span class="test"></span></div>');
      var span = this.fixture.querySelector('.test');
      diff.outerHTML(this.fixture, '<div><span>whatever</span></div>');

      assert.equal(this.fixture.innerHTML, '<span>whatever</span>');
      assert.equal(this.fixture.firstChild, span, 'are the same element');
    });

    it('supports html5 entities', function() {
      diff.outerHTML(this.fixture, '<div>&gla;</div>');

      assert.equal(this.fixture.innerHTML, '⪥');
    });
  });

  describe('Attributes', function() {
    it('can set attributes to empty', function() {
      diff.outerHTML(this.fixture, '<div class="hello"></div>');
      diff.outerHTML(this.fixture, '<div class=""></div>');

      assert.equal(this.fixture.outerHTML, '<div></div>');
    });

    it('can change attributes', function() {
      diff.outerHTML(this.fixture, '<div class="hello"></div>');

      assert.equal(this.fixture.className, 'hello');
    });

    it('can change attributes more than once', function() {
      diff.outerHTML(this.fixture, '<div class="hello"></div>');
      diff.outerHTML(this.fixture, '<div class="hello to you"></div>');

      assert.equal(this.fixture.className, 'hello to you');
    });

    it('supports inline styles', function() {
      diff.outerHTML(this.fixture,
        '<div><p style="font-size: 11px"></p></div>');
{'fraction_non_alphanumeric': 0.19230769230769232, 'fraction_numerical': 0.0013542795232936078, 'mean_word_length': 3.884259259259259, 'pattern_counts': {'":': 0, '<': 127, '<?xml version=': 0, '>': 127, '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': '88646', 'n_tokens_mistral': 2333, 'n_tokens_neox': 2240, 'n_words': 394}