Skip to content
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

fix(types): ensure toggleClass's second arg is optional #8829

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions src/js/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
*
*/

/**
Expand All @@ -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}
Expand Down