ReviewOS

stacks/ts-maps

Test DOM: classList.toggle(name, false) adds the class

#6267
Closed chris opened this 9 days ago ·
9 days ago

very-happy-dom (the test DOM, registered in test/preload.ts) implements classList.toggle(name, false) wrongly: it adds the class instead of removing it. Browsers remove it.

const d = document.createElement('div')
d.classList.toggle('a', false)
d.className // "a" — should be ""

SearchControl now uses explicit add/remove because of this. Other code still uses toggle(name, force) and could hide bugs in tests: OfflineMapsControl, SearchControl._show, LocateControl and others.

Scope

  • Fix upstream in very-happy-dom and bump the dependency.
  • Until then, add a test that pins the expected behaviour, so the upgrade is noticed.

Sign in to comment on this issue.