- From: Nathan Knowler <notifications@github.com>
- Date: Mon, 04 Nov 2024 06:05:37 -0800
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/issues/1029/2454804303@github.com>
I have a use case (which might resemble many other use cases).
I want to create a “current nav link” element. Today, I would use the following markup:
```html
<a href=/>Home</a>
<a href=/about aria-current=page>About</a>
```
Instead, I’d like to use a custom attribute called `nav-link`, so that I don’t need to change the markup with the current state for every page:
```html
<a href=/ nav-link>Home</a>
<a href=/about nav-link>About</a>
```
Instead of sprouting additional attributes, I’d like the `nav-link` custom attribute to be able to implicitly set `aria-current=page` for its attached element. Then I’d like to style the current nav link with a custom CSS state selector like this:
```css
a[nav-link]:state(current) {
text-decoration-thickness: 3px;
}
```
Both require `ElementInternals` access which raises some issues:
1. Currently built-ins don’t allow for accessing internals.
2. It seems like `Element` `attachInternals()` is likely a no-go since that can only be called once. There would need to be another way for custom attributes to access internals (perhaps a parameter for `attachInternals()` that could allow custom attributes access).
--
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/1029#issuecomment-2454804303
You are receiving this because you are subscribed to this thread.
Message ID: <WICG/webcomponents/issues/1029/2454804303@github.com>
Received on Monday, 4 November 2024 14:05:41 UTC