Skip to content

Selector could also be the element itself instead of id #17

@matmper

Description

@matmper

I will leave two important points that made me give up using BVSelect, even though it visually meets my needs.

  • The selector cannot be an Element, only an ID is completely limiting, making dynamic use difficult. This was the main point for giving up!

  • The code scans the document countless times to pick up other elements

Something like that to instance element selector:

if (typeof selector === "string" ) {
    switch (selector.charAt(0)) {
        case '.':
            selector = selector.substring(1);
            this.element = document.getElementsByClassName(selector);
            break;
        default:
            if (selector.charAt(0) === "#") {
                selector = selector.substring(1);
            }
            this.element = document.getElementsByClassName(selector);
            break;
    }
} else if (selector instanceof Element) {
    this.element = selector;
} else {
    throw new Error("Invalid selector");
}

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