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

Refactor ElementError class #4300

Closed
1 of 3 tasks
Tracked by #3478
domoscargin opened this issue Oct 4, 2023 · 1 comment · Fixed by #4349
Closed
1 of 3 tasks
Tracked by #3478

Refactor ElementError class #4300

domoscargin opened this issue Oct 4, 2023 · 1 comment · Fixed by #4349
Assignees
Milestone

Comments

@domoscargin
Copy link
Contributor

domoscargin commented Oct 4, 2023

What

Potential changes include:

  • Ensuring ElementError.options.expectedType is always a string, when present
  • Simplifying expected type error messages to something like ${identifier} is not of type ${expectedType || 'HTMLElement'}
  • Make identifier the mandatory first param and move element into options:

constructor(identifier, {componentName, element, expectedType})

Why

Making expectedType a string allows us to avoid having different cases for when it's a string vs when it's an element, reducing our checks and allowing us to simplify the outputted message.

Using identifier as our mandatory param allows us to avoid the hack of passing in null as the element to get the right error messages.

Who needs to work on this

Developer

Who needs to review this

Developer

Done when

  • A decision has been made on which changes to make
  • Changes have been implemented
  • All existing tests and throws have been refactored to work with the changes
@romaricpascal
Copy link
Member

Little note to make sure we account for the Skip Link's error when there's no hash in the URL, which may need its own little case (see end of that comment on #4299).

@domoscargin domoscargin self-assigned this Oct 16, 2023
@romaricpascal romaricpascal moved this from To discuss to Ready to release 🚀 in GOV.UK Design System cycle board Oct 23, 2023
@36degrees 36degrees moved this from Ready to release 🚀 to Done 🏁 in GOV.UK Design System cycle board Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants