Commit f365c731 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3243553 by nod_, lauriii: Fix destroy method

parent db882cc3
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ class _A11yAutocomplete {
      DOWN: 40,
    });

    this.originalInput = input.cloneNode();
    this.input = input;

    this.count = document.querySelectorAll('[data-autocomplete-input]').length;
@@ -1209,7 +1210,7 @@ class _A11yAutocomplete {
        );
      });
    });
    this.ul.remove();
    this.wrapper.parentNode.replaceChild(this.originalInput, this.wrapper);

    /**
     * Fires after the instance is destroyed.
+5 −5
Original line number Diff line number Diff line
@@ -190,17 +190,17 @@ describe('autocomplete', () => {

  it('option allowRepeatValues', async () => {});

  // @todo fix the library :)
  it('api .destroy()', async () => {
    const originalHtml = `<div><input data-autocomplete></div>`;
    const originalInput = `<input data-autocomplete="">`;
    const childrenSelector =
      'ul[data-autocomplete-item-list],span[data-autocomplete-live-region]';
    const wrapper = await fixture(originalHtml);
    const auto = A11yAutocomplete(wrapper.firstChild);
    const wrapper = await fixture(`<div>${originalInput}</div>`);
    const input = wrapper.firstChild;
    const auto = A11yAutocomplete(input);
    expect(wrapper).dom.descendants(childrenSelector).and.have.length(2);

    auto.destroy();
    //expect(wrapper).dom.to.have.html(originalHtml);
    expect(wrapper).dom.to.have.html(originalInput);
  });

  it('api .id', async () => {