Skip to content

BUG: class attribute invalid cache causes removed names to return #1812

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

Open
ncpa0cpl opened this issue May 5, 2025 · 0 comments
Open

BUG: class attribute invalid cache causes removed names to return #1812

ncpa0cpl opened this issue May 5, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ncpa0cpl
Copy link

ncpa0cpl commented May 5, 2025

Describe the bug
When an element class is removed it can magically come back after adding a new name to the class list.

To Reproduce
Steps to reproduce the behavior:

const elem = document.createElement("div");
elem.classList.add("foo", "bar", "baz");
expect(elem.outerHTML).toEqual("<div class=\"foo bar baz\"></div>");
elem.className = "";
elem.classList.add("bar", "baz");
expect(elem.outerHTML).toEqual("<div class=\"bar baz\"></div>");

run the above code and see it fail, the actual html of elem.outerHTML has the foo class name

Expected behavior
class names should not re-appear after being removed

Screenshots
Image
Image

Device:

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22] 17.4.6

Additional context
I've done some debugging and to me it seems like the cached value of the class attribute is incorrect (the cache.attributeValue is an empty string but the cache.items has the old entries in it. (see above screenshot)

@ncpa0cpl ncpa0cpl added the bug Something isn't working label May 5, 2025
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

No branches or pull requests

1 participant