USWDS - Core: Simplify and add test coverage for resolveIdRefs utility #6313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Simplified and added test coverage for the
resolveIdRefsutility added in #6308, per recommendations in #6310.Breaking change
This would only be considered a breaking change if someone expected USWDS code to throw an error if specifying an
aria-controlsvalue on a password component referencing an element which doesn't exist. This is exceedingly unlikely, since unless someone were explicitly catching this error, the thrown error would have interrupted the initialization of the password component, causing the component to not function as expected.Related issue
Closes #6310
Preview link
Preview link: http://localhost:6006/?path=/story/patterns-forms--sign-in
Problem statement
As a developer, I expect that USWDS will strive toward initializing components as gracefully as possible given the potential for invalid inputs, so that my website doesn't have broken controls.
As a end-user, I expect that USWDS will optimize its code so that feedback relevant for code development is not included in the production builds to end-users, so that pages download and load quickly.
As a developer, I expect that USWDS has full test coverage for its components and related utilities, to reduce the risk of bugs, and to make expected inputs and outputs more explicit.
Solution
resolveIdRefsresolveIdRefsresolveIdRefsTesting and review
Verify no regressions in the behavior of "Show password" toggle in the password component.
Before opening this PR, make sure you’ve done whichever of these applies to you:
git pull origin [base branch]to pull in the most recent updates from your base and check for merge conflicts. (Often, the base branch isdevelop).npm run prettier:sassto format any Sass updates.npm testand confirm that all tests pass.