Skip to content

Add option to avoid duplicating the original class attribute #344

@jcam5826

Description

@jcam5826

I upgraded my version of SumoSelect from version 3.0.3 to 3.4.8. There was a change made way back on 6/17/21 -- "feat: Pass origin class to generated element. Fixes [#294]". Which copies the class from the original select element to the ".CaptionCont.SelectBox" div element. This causes a problem on my legacy code which I have to remedy by undoing the duplicate classes:

const $select = $(".foo").SumoSelect();
$select.parent().find(".CaptionCont").removeClass($select.attr("class"));

It would be nice if an option existed that would prevent this duplication of classes.

I think the original issue #294, was simply requesting that an argument can be passed in to define what extra classes should be added to the generated element -- not necessarily forcing the parent's class to be duplicated. Maybe you can revisit the original request and if a class name is actually passed in, it would use the class name INSTEAD of duplicating the class name of the original select element. The duplication is unexpected and would be easy for someone who later selects elements based on only a class name, $(".foo)" to end up being surprised that they also picked up the ".CaptionCont" div -- granted a more specific selection of $("select.foo") would have been more prudent.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions