Quantcast
Channel: Scott O’Hara - Accessibility engineer, UX developer and designer
Viewing all articles
Browse latest Browse all 49

New in ARIA 1.2: ARIA IDL attributes

$
0
0

One of the new features coming in the ARIA 1.2 specification is the ability to specify ARIA attributes using the new ARIA IDL interfaces.

Prior to ARIA 1.2, if you needed to specify an ARIA attribute (role or any aria-* attribute) on an element, you would have to use the setAttribute method. For instance:

<divclass="chk">Accept my terms!</div><script>constchk=document.querySelector('.chk');chk.setAttribute('role','checkbox');chk.setAttribute('aria-checked','false');chk.tabIndex=0;// ...</script>

With the new ARIA IDL interfaces the above JavaScript can be more succinctly written as:

constchk=document.querySelector('.chk');chk.role='checkbox';chk.ariaChecked=false;// ...

or even:

constchk=document.querySelector('.chk');Object.assign(chk,{role:'checkbox',ariaChecked:false,// ...});

Presently Firefox lacks support for the role and all the aria-* IDL attributes. Chromium browsers support all the aria-* IDL attributes exceptariaInvalid. They lack support for the role IDL attribute as well. Safari is missing support for ariaDescription.

EDIT:James Nurthen, one of ARIA’s editors also wants you (me. he means me.) all to know that support for the aria-* attributes that can take multiple IDRefs is non-existant at the time of writing this post.

Essentially, if you wanted to specify aria-labelledby="id1 id2 id3", or any other aria-* attribute that can list a series of IDrefs, then that’s not possible at this time. The following is a list of attributes that do not have a corresponding IDL attribute, yet:

  • aria-activedescendant
  • aria-controls
  • aria-describedby
  • aria-details
  • aria-errormessage
  • aria-flowto
  • aria-labelledby
  • aria-owns
  • aria-relevant

And the following two attributes will likely not receive IDL attributes, as they have been marked as deprecated in the ARIA specification:

  • aria-dropeffect
  • aria-grabbed

The following table will populate the “support result” column with a “pass” or “fail” depending on the browser you are using. So if any of the above information changes, the table will call me out on my outdated information.

Note:aria-description is not acutally part of ARIA 1.2, but rather ARIA 1.3. I fogot this, but don’t want to remove it from the below table. So there it stays.

IDL AttributeReflected ARIA Attribute
& tested value
Support result
rolerole
ariaAtomicaria-atomic
ariaAutoCompletearia-autocomplete
ariaBusyaria-busy
ariaCheckedaria-checked
ariaColCountaria-colcount
ariaColIndexaria-colindex
ariaColSpanaria-colspan
ariaCurrentaria-current
ariaDescriptionaria-description
ariaDisabledaria-disabled
ariaExpandedaria-expanded
ariaHasPopuparia-haspopup
ariaHiddenaria-hidden
ariaInvalidaria-invalid
ariaKeyShortcutsaria-keyshortcuts
ariaLabelaria-label
ariaLevelaria-level
ariaLivearia-live
ariaModalaria-modal
ariaMultiLinearia-multiline
ariaMultiSelectablearia-multiselectable
ariaOrientationaria-orientation
ariaPlaceholderaria-placeholder
ariaPosInSetaria-posinset
ariaPressedaria-pressed
ariaReadOnlyaria-readonly
ariaRequiredaria-required
ariaRoleDescriptionaria-roledescription
ariaRowCountaria-rowcount
ariaRowIndexaria-rowindex
ariaRowSpanaria-rowspan
ariaSelectedaria-selected
ariaSetSizearia-setsize
ariaSortaria-sort
ariaValueMaxaria-valuemax
ariaValueMinaria-valuemin
ariaValueNowaria-valuenow
ariaValueTextaria-valuetext

Until Firefox gets cracking on implementing these (and Chromium implements role– which is kind of a big deal and ariaInvalid), we should generally wait to use these IDL attributes. Even when fully implemented, it’d likely be best to wait a few version releases thereafter. You know, just for those few browser updating stragglers (whether it be due to their own inability to update when prompted – I will raise my hand here, or because their system is locked down and they can’t update freely).

But hey, you working on a project that is sure to be viewed by Webkit only (e.g., a webview in an iOS application). Or are you working on an Electron desktop app, which uses Chromium under the hood? Then you might be able to use the supported IDL attributes today.


Viewing all articles
Browse latest Browse all 49

Trending Articles