feat: Apply aria-current: 'page' for active links as default aria- value#112
Merged
feat: Apply aria-current: 'page' for active links as default aria- value#112
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements default ARIA attributes for active links by applying aria-current="page" automatically when no custom aria attributes are specified. The implementation introduces a new utility function to expand shorthand ARIA attributes and updates the LinkContext to derive expanded aria attributes.
- Adds
expandAriaAttributesutility function to convert shorthand ARIA notation (e.g.,{ current: 'page' }) to full attribute names (e.g.,{ 'aria-current': 'page' }) - Implements default
aria-current="page"behavior for active links when no aria configuration is provided - Updates LinkContext to track and derive expanded aria attributes from the activeState
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/utils.ts | Adds expandAriaAttributes function to convert shorthand aria attributes to full aria-* format |
| src/lib/utils.test.ts | Adds comprehensive test coverage for the new expandAriaAttributes utility function |
| src/lib/LinkContext/LinkContext.svelte.test.ts | Updates tests to use shorthand aria notation and adds tests for activeStateAria derivation |
| src/lib/LinkContext/LinkContext.svelte | Adds activeStateAria derived property to LinkContext class |
| src/lib/Link/Link.svelte.test.ts | Adds tests for default aria-current behavior and empty object override |
| src/lib/Link/Link.svelte | Refactors aria attribute calculation to use new utility and apply defaults |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #107.
Now, the attribute
[aria-current="page"]is applied to active links by default if no value foractiveState.ariais provided.To disable the default, set
activeState.ariato an empty object.