W3C home > Mailing lists > Public > www-style@w3.org > July 2013

Re: [selectors4] Request for :role() selector (matches computed role using UA internals, not attribute substring matching)

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 3 Jul 2013 12:29:26 -0700
Message-ID: <CAAWBYDCnQoYC7V6atnoiUZ-zFsFQB+Pc-MeqbzE2gCdWqWOt4A@mail.gmail.com>
To: James Craig <jcraig@apple.com>
Cc: www-style list <www-style@w3.org>
On Wed, Jul 3, 2013 at 12:20 PM, James Craig <jcraig@apple.com> wrote:
> I'd like to request an "applied role" selector. This can't be done with existing attribute substring matching as it relies on the user agent internals to determine a few things.
>
> 1. what the default role of a tag is.
> 2. which role has been applied if multiple roles or invalid roles have been specified in the role attribute.
>
> The following suggested selector:
>
>         :role('button')

Syntax nit: while our policy on values coming from outside sources is
generally to represent them as strings, all of the existing ARIA role
values are compatible with the ident syntax, and I expect that to
continue to be true.  So it should just take an ident, like
:role(button).

> Part of the reason this needs to be a new selector is because whether or not a specific element matches the selector is dependent upon whether or not the rendering engine supports the expected role. For example, using this selector and element combination:
>
>         :role('checkbox')
>         <div role="foo switch checkbox">
>
> In most browsers today, the selector would match, because "foo" and "switch" are not valid ARIA 1.0 roles. However, in an ARIA 1.1-compliant browser, the same selector/element combination would not match, because the updated browser applied the 1.1 "switch" role instead of the fallback 1.0 "checkbox" role.

What sort of things would you use this selector for?  I don't think
you can generally style things according to their role; the precise
element used can vary considerably and affect what styles work.  Is
there a use related to JS?

~TJ
Received on Wednesday, 3 July 2013 19:30:13 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 3 July 2013 19:30:14 UTC