1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-03 00:57:02 +02:00

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

## Description
Generated types are mangled for `Component.toggleClass()`, because tsc
doesn't understand `~` namespaces. The second arg is then not marked as
optional.

## Specific Changes proposed
Refactor JSDoc

## Requirements Checklist
- [x] Feature implemented / Bug fixed
- [ ] If necessary, more likely in a feature request than a bug fix
- [ ] Change has been verified in an actual browser (Chrome, Firefox,
IE)
  - [ ] Unit Tests updated or fixed
  - [ ] Docs/guides updated
- [ ] Example created ([starter template on
JSBin](https://codepen.io/gkatsev/pen/GwZegv?editors=1000#0))
- [x] Has no DOM changes which impact accessiblilty or trigger warnings
(e.g. Chrome issues tab)
  - [x] Has no changes to JSDoc which cause `npm run docs:api` to error
- [ ] Reviewed by Two Core Contributors
This commit is contained in:
mister-ben
2024-08-14 21:00:01 +02:00
committed by GitHub
parent e715145d86
commit 65f8546782
2 changed files with 8 additions and 7 deletions

View File

@ -983,10 +983,10 @@ class Component {
* - `classToToggle` gets removed when {@link Component#hasClass} would return true. * - `classToToggle` gets removed when {@link Component#hasClass} would return true.
* *
* @param {string} classToToggle * @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] * @param {boolean|Dom.PredicateCallback} [predicate]
* An {@link Dom~predicate} function or a boolean * A boolean or function that returns a boolean. Passed to DOMTokenList's toggle().
*/ */
toggleClass(classToToggle, predicate) { toggleClass(classToToggle, predicate) {
Dom.toggleClass(this.el_, classToToggle, predicate); Dom.toggleClass(this.el_, classToToggle, predicate);

View File

@ -262,7 +262,7 @@ export function removeClass(element, ...classesToRemove) {
/** /**
* The callback definition for toggleClass. * The callback definition for toggleClass.
* *
* @callback module:dom~PredicateCallback * @callback PredicateCallback
* @param {Element} element * @param {Element} element
* The DOM element of the Component. * The DOM element of the Component.
* *
@ -271,8 +271,9 @@ export function removeClass(element, ...classesToRemove) {
* *
* @return {boolean|undefined} * @return {boolean|undefined}
* If `true` is returned, the `classToToggle` will be added to the * If `true` is returned, the `classToToggle` will be added to the
* `element`. If `false`, the `classToToggle` will be removed from * `element`, but not removed. If `false`, the `classToToggle` will be removed from
* the `element`. If `undefined`, the callback will be ignored. * the `element`, but not added. If `undefined`, the callback will be ignored.
*
*/ */
/** /**
@ -285,7 +286,7 @@ export function removeClass(element, ...classesToRemove) {
* @param {string} classToToggle * @param {string} classToToggle
* The class that should be toggled. * 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} * See the return value for {@link module:dom~PredicateCallback}
* *
* @return {Element} * @return {Element}