Skip to content

Commit

Permalink
Use JSDoc @callback for nodeListForEach()
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Oct 12, 2022
1 parent e42c611 commit 7817577
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/govuk/common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import './vendor/polyfills/Element/prototype/closest.mjs'
* See: https://github.com/imagitama/nodelist-foreach-polyfill
*
* @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
* @param {(value: Element, key: number, parent: NodeListOf<Element>) => void} callback - Callback function to run for each node
* @param {nodeListIterator} callback - Callback function to run for each node
* @returns {void}
*/
export function nodeListForEach (nodes, callback) {
Expand Down Expand Up @@ -213,3 +213,11 @@ export function closestAttributeValue ($element, attributeName) {
return closestElementWithAttribute.getAttribute(attributeName)
}
}

/**
* @callback nodeListIterator
* @param {Element} value - The current node being iterated on
* @param {number} index - The current index in the iteration
* @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
* @returns {void}
*/

0 comments on commit 7817577

Please sign in to comment.