Skip to content

Element.classList has empty string item when a class attribute contains multiple spaces #1168

@takenspc

Description

@takenspc

Describe the bug
Element.classList has empty string item when a class attribute contains multiple spaces. Multiple spaces should be compressed and Element.classList should not have empty string item.

To Reproduce
Steps to reproduce the behavior:

  1. Run following code:
const {Window} = require('happy-dom');
const {document} = new Window();
const element = document.createElement('div');
element.className = 'a  b';
const list = [...element.classList.values()];
console.log(list); // ['a', '', 'b']

Expected behavior
The expected result of list is ['a', 'b']. Other DOM implenetations including Google Chrome, Mozilla Firefox, and JSDOM return ['a', 'b'].

Device:

  • OS: Windows 11
  • Browser: Google Chrome and Mozilla Fireefox
  • Version; happy-dom 12.10.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions