In my previous post, I mentioned that I’ve used the web install API in production. Specifically, I’ve used it on The Session. In order to do that, I had to register for the origin trial.

I’ve just signed up for another origin trial. This time it’s for the proposed focusgroup attribute:

The focusgroup HTML attribute is a proposed declarative way to add keyboard arrow-key navigation to composite widgets such as toolbars, tablists, menus, listboxes, etc. without writing any roving-tabindex JavaScript. One attribute replaces hundreds of lines of boilerplate.

I’ve got an HTML web component on The Session called tab-controls. And yes, there’s a bunch of code in there to listen for keyboard events and respond appropriately. I would very much like to rip that code out.

So now that I’ve opted into the origin trial, I’ve added this to my HTML:

<tab-controls role="tablist" focusgroup="tablist">

If this focusgroup attribute takes off, I’ll be able to remove the role attribute but for now, it’s very much needed.

In the JavaScript for my tab-controls custom element, I need to be able to detect support for focusgroup. Here’s how I’m doing it:

if (!this.focusgroup) {
// do all my key handling stuff here
}

Here’s the important thing: don’t use getAttribute('focusgroup') to test for browser support. That will return true if the attribute is in the HTML. But the attribute will only get converted into a property if the browser understands it.

Jake has a lot more detail on the differences between attributes and properties.

Anyway, I figured I’d share that little snippet in case you too were interested in trying out the focusgroup proposal using progressive enhancement.

Responses

Related posts

Related links

Official Google Webmaster Central Blog [EN]: More options to help websites preview their content on Google Search

Google’s pissing over HTML again, but for once, it’s not by making up rel values:

A new way to help limit which part of a page is eligible to be shown as a snippet is the “data-nosnippet” HTML attribute on span, div, and section elements.

This is a direct contradiction of how data-* attributes are intended to be used:

…these attributes are intended for use by the site’s own scripts, and are not a generic extension mechanism for publicly-usable metadata.

Tagged with

Previously on this day

1 year ago I wrote Sessioning

Playing jigs’n’reels every night.

4 years ago I wrote When should there be a declarative version of a JavaScript API?

If the JavaScript API requires a user gesture, maybe it’s time for a new button type.

5 years ago I wrote March

Out of the ordinary.

5 years ago I wrote Content buddy

Moving words around.

6 years ago I wrote 41 hours in Galway

A weekend of food and music to celebrate my birthday.

7 years ago I wrote Handing back control

An emergent theme at An Event Apart Seattle 2019.

7 years ago I wrote Updating email addresses with Mailchimp’s API

A change in version 3 of Mailchimp’s API.

8 years ago I wrote A workshop on building for resilience

The progressive web: a day-long workshop.

11 years ago I wrote Huffduffing video

Now you can grab the audio from YouTube and Vimeo videos for your huffduffing pleasure.

17 years ago I wrote Crawlbar

Say it with me.

21 years ago I wrote Perfect timing

Just in time for South by SouthWest, the Washington post has published an article called “Texas Eat ‘Em” about barbecue in the Lone Star State:

22 years ago I wrote We'll always have Paris

I’m back from my weekend in Paris.

24 years ago I wrote Trout Thursday

Only 327 days to go.