Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
takenspc opened this issue Nov 24, 2023 · 0 comments · Fixed by #1169
Closed
Labels
bug Something isn't working

Comments

@takenspc
Copy link
Contributor

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
@takenspc takenspc added the bug Something isn't working label Nov 24, 2023
takenspc added a commit to takenspc/happy-dom that referenced this issue Nov 24, 2023
takenspc added a commit to takenspc/happy-dom that referenced this issue Nov 24, 2023
takenspc added a commit to takenspc/happy-dom that referenced this issue Nov 24, 2023
takenspc added a commit to takenspc/happy-dom that referenced this issue Nov 24, 2023
takenspc added a commit to takenspc/happy-dom that referenced this issue Nov 28, 2023
takenspc added a commit to takenspc/happy-dom that referenced this issue Nov 28, 2023
* String.prototype.split() accepts RegExp.
* RegExp's g flag is ignored in split() so that g flag was removed.
capricorn86 added a commit to takenspc/happy-dom that referenced this issue Jan 14, 2024
capricorn86 added a commit to takenspc/happy-dom that referenced this issue Jan 14, 2024
capricorn86 added a commit that referenced this issue Jan 14, 2024
#1168@patch: Normalize whitespace in processing of DOMTokenList.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant