TiddlyWiki5/core/modules/utils
pmario 005e175378 Fix RSOD when $tw.utils.addClass receives a class string with whitespace
PR #9251 replaced the manual setAttribute("class", ...) implementation of
$tw.utils.addClass/removeClass/toggleClass with direct Element.classList
calls. Unlike setAttribute, classList.add/remove/toggle throws
InvalidCharacterError on any token containing whitespace, so callers that
pass a whole class string (e.g. modal.js passing tiddler.fields.class)
now crash.

Manual repro on tw5-com: open SampleWizard, set the `class` field to
"aaa bbb", Done, open popup -> OK -> open nested popup -> RSOD.

Fix: split the className argument on whitespace in deprecated.js and feed
individual tokens to classList. A small splitClasses() helper keeps the
three functions symmetrical.

Adds adversarial regression tests in test-utils.js covering:
- ASCII whitespace variants (space, tab, CR, LF, mixed runs, padding)
- Unicode whitespace (U+00A0 non-breaking space)
- de-duplication across single and multiple calls
- remove/toggle no-op on missing tokens
- toggle with status undefined / true / false
- silent no-op for whitespace-only / empty / non-string / null input
- silent no-op when the element has no classList
2026-04-22 17:15:35 +02:00
..
diff-match-patch Migrate diff-match-patch to a modern fork (#9511) 2026-01-04 11:56:25 +00:00
dom fix: zoomin storyview should not remove CSS properties when element is already removed (#9686) 2026-02-23 08:59:32 +01:00
base64.js Fixes ESLint errors (#9668) 2026-02-20 08:38:42 +00:00
crypto.js Remove module function wrapper and add matching configurations for dprint and eslint (#7596) 2025-03-21 17:22:57 +00:00
csv.js Fixes ESLint errors (#9668) 2026-02-20 08:38:42 +00:00
deprecated.js Fix RSOD when $tw.utils.addClass receives a class string with whitespace 2026-04-22 17:15:35 +02:00
errors.js Recurse exception handling to better handle '{{}}' in place of recently installed fix (#9548) 2026-02-04 11:21:16 +00:00
escapecss.js Split escapecss into two platforms (#9475) 2026-01-20 12:13:48 +01:00
fakedom.js Fixes ESLint errors (#9668) 2026-02-20 08:38:42 +00:00
linked-list.js Fixes ESLint errors (#9668) 2026-02-20 08:38:42 +00:00
logger.js Fixes ESLint errors (#9668) 2026-02-20 08:38:42 +00:00
messaging.js fix: remove fn wrappers and unneeded comments (#9637) 2026-02-05 17:06:32 +01:00
parsetree.js feat: serialize AST node back to wikitext string (#8258) 2025-10-29 21:21:36 +00:00
performance.js Fixes ESLint errors (#9668) 2026-02-20 08:38:42 +00:00
pluginmaker.js Fixes ESLint errors (#9668) 2026-02-20 08:38:42 +00:00
transliterate.js Fixes ESLint errors (#9668) 2026-02-20 08:38:42 +00:00
utils.js Fixes ESLint errors (#9668) 2026-02-20 08:38:42 +00:00