Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

[QUESTION] ambiguous method call inside "refreshItems" method #2239

Open

Description

@the-liquid-metal

Hi.

I am exploring the Selectize codebase. I found this line inside refreshItems method:
this.addItem(this.items);
I also found this line inside addItem method:
value = hash_key(value);

since addItem method signature is function(value, silent), the value must be undefined, null, boolean, number, or string. If we feed addItem with array, value = hash_key(value); will produce incorrect value.

In addition to addItem, there is a corresponding method called addItems. There is no value = hash_key(value); statement (or anything similar) inside addItems. Moreover, addItem is called inside addItems: this.addItem(items[i], silent);.

Is it already correct (the this.addItem(this.items); statement inside refreshItems method),
or hidden bug (it should be this.addItems(this.items);)?

Activity

  1. the-liquid-metal commented on Dec 10, 2025

    @the-liquid-metal
    Author

    After reading more carefully, I found that this.addItem(this.items); will never be executed!
    That statement is wrapped by if (this.isSetup), and refreshItems only called inside setup. The final value of if (this.isSetup) is ALWAYS false.

    Moreover, of the 4 statements in refreshItems, only one is significant. the details are:

    1. this.lastQuery = null; is unique and will be executed.
    2. this.addItem(this.items, silent); is unique and will never be executed.
    3. this.refreshState(); is NOT unique and will be executed.
    4. this.updateOriginalInput({silent: silent}); is NOT unique and will be executed.

    IMHO, the existence of refreshItems is redundant since it’s only called in one place, contains only a single meaningful statement, and adds unnecessary overhead.

  2. github-actions commented on Apr 10, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions