From 565c4e2777612314036cc65f1d571fdc9f70a354 Mon Sep 17 00:00:00 2001 From: mister-ben <1676039+mister-ben@users.noreply.github.com> Date: Tue, 13 Aug 2024 22:43:23 +0200 Subject: [PATCH] fix(types): toggleClass second arg is optional --- src/js/component.js | 6 +++--- src/js/utils/dom.js | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/js/component.js b/src/js/component.js index 4340eed558..1b86498f7b 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -983,10 +983,10 @@ class Component { * - `classToToggle` gets removed when {@link Component#hasClass} would return true. * * @param {string} classToToggle - * The class to add or remove based on (@link Component#hasClass} + * The class to add or remove. Passed to DOMTokenList's toggle() * - * @param {boolean|Dom~predicate} [predicate] - * An {@link Dom~predicate} function or a boolean + * @param {boolean|Dom.PredicateCallback} [predicate] + * A boolean or function that returns a boolean. Passed to DOMTokenList's toggle(). */ toggleClass(classToToggle, predicate) { Dom.toggleClass(this.el_, classToToggle, predicate); diff --git a/src/js/utils/dom.js b/src/js/utils/dom.js index 095825e7c5..0505850064 100644 --- a/src/js/utils/dom.js +++ b/src/js/utils/dom.js @@ -262,7 +262,7 @@ export function removeClass(element, ...classesToRemove) { /** * The callback definition for toggleClass. * - * @callback module:dom~PredicateCallback + * @callback PredicateCallback * @param {Element} element * The DOM element of the Component. * @@ -271,8 +271,9 @@ export function removeClass(element, ...classesToRemove) { * * @return {boolean|undefined} * If `true` is returned, the `classToToggle` will be added to the - * `element`. If `false`, the `classToToggle` will be removed from - * the `element`. If `undefined`, the callback will be ignored. + * `element`, but not removed. If `false`, the `classToToggle` will be removed from + * the `element`, but not added. If `undefined`, the callback will be ignored. + * */ /** @@ -285,7 +286,7 @@ export function removeClass(element, ...classesToRemove) { * @param {string} classToToggle * The class that should be toggled. * - * @param {boolean|module:dom~PredicateCallback} [predicate] + * @param {boolean|PredicateCallback} [predicate] * See the return value for {@link module:dom~PredicateCallback} * * @return {Element}