Skip to content

Can we use protected method instead of private method? #105

@ln8711

Description

@ln8711

Hi,
In the previous version, I can simply override the method from the package (to better handle text in Vietnamese)

function convertVietnamese(str) {
    return str
        .normalize("NFD")
        .replace(/[\u0300-\u036f]/g, "")
        .replace(/đ/g, "d")
        .replace(/Đ/g, "D");
};

NiceSelect.prototype._onSearchChanged = function(e) {
    var open = hasClass(this.dropdown, "open");
    var text = e.target.value;
    text = convertVietnamese(text.toLowerCase());
  
    if (text == "") {
      this.options.forEach(function(item) {
        item.element.style.display = "";
      });
    } else if (open) {
      var matchReg = new RegExp(text);
      this.options.forEach(function(item) {
        var optionText              = convertVietnamese(item.data.text.toLowerCase());
        var matched                 = matchReg.test(optionText);
        item.element.style.display  = matched ? "" : "none";
      });
    }
  
    this.dropdown.querySelectorAll(".focus").forEach(function(item) {
      removeClass(item, "focus");
    });
  
    var firstEl = this._findNext(null);
    addClass(firstEl, "focus");
};

Now the method has been changed into private aka #onSearchChanged
Is that possible switch back to old method instead using private one?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions