Skip to content

Conversation

@webJose
Copy link
Contributor

@webJose webJose commented Nov 11, 2025

Closes #107.

Now, the attribute [aria-current="page"] is applied to active links by default if no value for activeState.aria is provided.

To disable the default, set activeState.aria to an empty object.

@webJose webJose requested a review from Copilot November 11, 2025 23:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 expandAriaAttributes utility 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>
@webJose webJose merged commit 4ff7199 into main Nov 12, 2025
1 check passed
@webJose webJose deleted the JP/Default_Aria branch November 12, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maybe re-add the default aria-current for active routes

2 participants