Skip to content

Uize.Node.Classes reports incorrect state #27

@BenAtZazzle

Description

@BenAtZazzle

Uize.Node.Classes has a bug in with respect to how it tests if a string is a class w/in the className property. This is easily seen with Uize.Node.Classes.hasClass.

Let's say we have the following node:

<div id="foo" class="bar-bat baz">Test</div>

And we execute the following code:

Uize.Node.Classes.hasClass('foo', 'bar')

This will return true even tho bar is not a class of the foo div. Looking deep into the code, it appears that the regular expression used to determine if a string is in the className uses a word boundary (\b) which works for spaces or the beginning/end of the className, but also targets hyphens which are actually a valid CSS character.

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