Skip to content

addClass() called with an array doesn't add all of the classes if one of them is an empty string #4998

Closed
@MatmaRex

Description

@MatmaRex

Description

When addClass() is called with an array, and one of the classes in the array is an empty string, it doesn't add all of the classes (it stops processing them after the empty string).

Minimal test case:

$( '<div>' ).addClass( [ 'a', '', 'b' ] ).attr( 'class' )

Expected output: a b
Actual output: a

Link to test case

https://jsbin.com/voxetucoho/edit?js,console

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions