Skip to content

Commit

Permalink
Prefer not to use destructuring with default values
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Sep 18, 2023
1 parent 1deaeb0 commit 090e1b6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/govuk-frontend/src/govuk/errors/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ export class ElementError extends GOVUKFrontendError {

/**
* @param {Element} element - The element in error
* @param {object} options - options
* @param {object} options - Element error options
* @param {string} options.componentName - The name of the component throwing the error
* @param {string} options.identifier - An identifier that'll let the user understand which element has an error (variable name, CSS selector)
* @param {typeof HTMLElement} [options.expectedType] - The type that was expected for the element
*/
constructor(
element,
{ componentName, identifier, expectedType = HTMLElement }
) {
constructor(element, { componentName, identifier, expectedType }) {
expectedType = expectedType || HTMLElement

const reason = !element
? `${identifier} not found`
: `${identifier} is not an instance of "${expectedType.name}"`
Expand Down

0 comments on commit 090e1b6

Please sign in to comment.