-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add language to http://ampersandjs.com/learn/role-attribute to discuss accessibility implications #21
Comments
Hey @AmpersandJS people. This issue is important. The basis of your recommendations for using a role attribute are sound -- preventing collisions between devs and designers in use of A better solution is to recommend For your own code, find and replace |
Related: http://www.w3.org/wiki/PF/XTech/HTML5/RoleAttribute#ARIA_1.0_Pre-Defined_Roles (ARIA reserved roles) |
We most certainly don't want to cause problems for accessibility. My question currently is just if it's better to avoid using them or to add as much semantic value to the doc as possible? There's a potentially nice overlap in this, in that JS also cares about the element's purpose in the app. So, perhaps encouraging people to use it may actually be a net gain in accessibility where most won't add roles at all otherwise? If we could accomplish that, that'd be awesome. If it turns out that's not the case we'll certainly change the recommendation. I'm still looking for a definitive resource or expert in how they're actually used for accessibility. Help in figuring this out would be much appreciated. |
@HenrikJoreteg this is the resource we were trying to find http://www.w3.org/wiki/PF/XTech/HTML5/RoleAttribute#ARIA_1.0_Pre-Defined_Roles I'm personally of the mind that in that light, and after re-reading the html definition on data- http://www.w3.org/TR/html5/dom.html#custom-data-attribute and seeing how it's explicitly not to be interpreted by anything outside the site itself, we should be using data- instead of role. |
My gut feeling is to think of ARIA as another separate concern. So let the CSS work from I've been using http://fluidproject.org/products/infusion/ They seem to be quite serious about an inclusive web. Google seems to think Mozilla's pages on ARIA are the place to start, but I think you might find the code in Infusion worth looking at. And perhaps it will be a case where Ampersand proves flexible enough to use Fluid components in the view to gain the benefits of their thinking on accessibility and inclusiveness. |
On a quick glance, I'm +1 on shifting the recommendation from role to data-, and updating getByRole in ampersand-view appropriately, as well as the various role selectors in, eg ampersand-dom-bindings. Given the wide range of roles already defined, and their use in accessibility, it doesn't make sense to me to try and compete with their use. Given how generic the roles are, it also doesn't make sense to me to try and overload them by trying to use them for both accessibility and js hooks. The question then is what should we switch to? The benefits of role were:
data-role="foobar" would be the obvious alternative, but that feels a bit weird as it's kinda confusing with role now, and getByRole gets more confusing. this proposes data-js, which has the benefit of being clearly related to JS, and is fairly short. Though, I don't know what you'd rename getByRole and the role shortcuts in ampersand-dom-binding to? |
+1 for |
I agree w/ the data-role feeling like it was an arbitrary decision that's based on the practice of having used role before. data-& is unfortunately invalid html :/ Without haven given much thought (so heads up on that) I feel like if we go with data-js the function becomes getByDataJs(foo) or getByData('js', foo) |
The nice thing about this is we can leave getByRole so as not to break anyone using that in production. REMOVING getByRole imo can be a totally different discussion i.e. do we deprecat now, do we have a timeline goal? |
|
Just my 2 cents. Just for the sake of creativity |
Some pondering I've gone back and forth on about this issue:
So, I'd like for any |
+1 FWIW, |
A few more options from the synonym finder: |
Great thoughts @legastero, 👍 on whatever solution supporting multiple roles. We can do that with Also, on @legastero's point about role allowing multiple attributes, I'm intrigued as to what the potential fallout of using non-aria roles in role is? I guess the concern is future collision, but that feels like a minor concern. Which I guess is back to @HenrikJoreteg's question of whether it's still actually okay to still use role, and just teach people how to also add proper accessible roles where it makes sense. |
I really like this idea; it allows us to transition to |
On discussion with @wraithgar I'm back to a firm 👍 on not using role, as it's just plain not meant for this, and I defer to @dobbs completely on the accessibility implications, so sorry for re-suggesting it in my last comment. I dislike data-role though. And I don't like data-js anymore. Maybe that's because I'm difficult :) |
data-hook, getByHook |
<div>
<h1 data-hook="name"></h1>
<div data-hook="profile-form"></div>
</div> bindings: {
'model.name': {
type: 'text',
hook: 'name'
}
}
subviews: {
profileForm: {
view: ProfileForm,
hook: 'profile-form'
}
} |
|
In a direct message w/ @latentflip I shot the idea of 'data-bind' down because it's wrapped up in my head w/ model bindings but not view bindings. However I think it's still important to bring up in case I'm completely wrong. |
Hook sounds pretty good :) |
The benefit of separating this concern from the The risk of putting names in There you have both a pro and con pointing towards separating completely from the role attribute. With regard to naming, I rather like the idea of |
Just a heads up we're thinking of changing .get() which could also change what this unnamed function is called. |
Knockout uses |
I dislike bind because that's not what we're doing, we're defining a selector for binding OR view insertion OR whatever else. It's a selector, not a binding. That knockout link is a great example of actual attribute binding, storing the binding info in that attribute. |
A few thoughts. Everyone keeps saying it might interfere with screenreaders so I tried it on the sample app that ampersand-cli generates. I used the chromevox screenreader extension from chrome: https://chrome.google.com/webstore/detail/chromevox/kgejglhpjiefppelpmljglcjbhoiplfn It reads text in the page containing what you click. Starting with headers, etc. To see what it did I added "navigation" (a known reserved role) as a role to the navbar, it read the contents of the nav, then simply said "navigation" when it was done reading the contents as additional context. It didn't read any of the other roles (like page-container) out loud. I'm afraid I disagree that our use of this goes against its intended purpose, here's the spec: http://www.w3.org/TR/role-attribute/ the abstract follows:
I don't know about you folks, but I never used to use role for anything, which meant I provided zero help to screen readers. Since encouraging use of I simply fail to see what damage is being done. If you can show me what we're doing that's causing harm for accessibility I'll be the first to push for a change. But, the way I see it, we have a chance to provide developers more incentive to markup their apps to make them better for accessibility and help draw attention to the need for doing it. I didn't know Role allows a clear, semantic mechanism for describing what its purpose is in the document. So, from what I'm hearing the "cons" can be summarized as: "someone will use a reserved role attribute to describe something that isn't actually playing that role and confuse the screenreader". I don't understand how that's even likely to happen. Why would I assign a role of "menu" or "list" or "button" or "navigation" to something that doesn't actually serve that semantic purpose? Apparently I'm in the minority, but I still see encouraging the use of role as a huge net positive for improving and increasing awareness of accessibility. If anything I think we should be encouraging developers to use the "reserved" roles where they semantically make sense. Other relevant reading on ARIA: https://developer.mozilla.org/en-US/docs/Web/Accessibility/An_overview_of_accessible_web_applications_and_widgets which explains how the use of the role attribute in combination with |
A potentially useful Stack Overflow answer: http://stackoverflow.com/a/18664038/107722 |
I like the idea of using this choice to encourage developers to learn the reserved role words for the sake of accessibility, which is always completely in line with semantically meaningful markup, and is also generally in line with meaningfully descriptive code. But if that’s what we’re doing, we’d of course need to also add that info and context to the ampersand role docs. :) |
Thanks @stevefaulkner! Current front runners for alternatives are I'm leaning toward |
In real world code I've used name to distinguish between form inputs I care about serializing and those I don't (I capture changes and do other things w/ those values instead) Also I like rel but the html5 spec does mention "acceptable values" which to me reads like a closed list. $.02 ETA getting links like this from Henrik's helpful request on twitter: http://microformats.org/wiki/existing-rel-values and I'm infinity percent less concerned about role breaking things on a random browser (which is something people usually QA for anyways) than I was about limiting accessibility (which sadly isn't on most QA radars). So my concerns w/ rel are miniscule. |
Sorry, but 'rel' is not like 'role'. And it's html5 btw. ;) html5 is about semantics and rel (relationship) is not a 'role'. |
What about css classes that follow a convention: (this is what Github uses for dom bindings) |
Before this dissolves into a long list of suggestions. Here's some outlines, since we've been back and forth this once in the past internally (which brought us to role in the first place). The following are listed without my own additional biases:
And the things this decision will affect are:
So the discussion probably should only revolve around shortcomings of the two "mights" above, unless there are any fresh ideas not covered by the above. Philip Roberts
|
I don't want to quibble over details but there's only one correct option: data-* |
Adding some more info: The spec for This validator: http://validator.w3.org/nu/ complains about using a strange rel on the <!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p rel="something"></p>
<a rel="otherthing" href="asdf"></a>
</body>
</html> |
Since I suggested it, (and not that my vote really counts, but...) I still think I know there's argument above about the "semantics" and what's appropriate. But anyone who lectures with a suggestion that there's any sort of "one true perfect semantic" for HTML5 tags and attributes hasn't really payed much attention. At best, "HTML5 semantics" are about "best fit" and "best effort". There's plenty of places where the "semantics" have been debated and debatable, and it generally comes down to judgement calls. In that spirit, here's how I define the semantic for using As for validation and collision of This is not just theory. I've done this many times on many different sites/apps, and we've never had any issues with search engines or other tools. If you end up not using |
it does not fail with More info on changes to sigh I dislike how long What about just making something up. All browsers deal with it fine and have for years. The precedent has certainly been set by angular with I'm leaning toward agreeing with @getify on this and just using
|
I'd avoid any reusing of older attributes who "mostly" work or "in most cases". It doesn't sound stable and trustworthy. And anyone who knows html5 can easily accept the fact that "role" belongs to a certain standard and therefore data-* has to be used. Regarding 'data-hook' I'd like to mention that a "hook" has a special meaning in certain coder communities (linux hackers, windows kernel level development etc.). A "hook" is a special procedure to "hook into a syscall". OK, sorry for the theory, I'm sure you know that already, but just in the case you show your code to some colleague who's hacking linux etc. ;) |
I agree with @brakmic. The Please don't follow angular's example and make up your own attribute prefix. Angular gets a LOT right, but that choice is going to bite them in the long run. XML has proved that namespaced attributes become difficult for people to use correctly. More importantly, you really only need one attribute to replace your existing use of If you really want shorter usages, there's another way to use those selectors. From your example...
OR
Both of those cases are the same character length as |
Actually after a little more thought... maybe |
I've seen Also |
A humble suggestion since it seems like data-* is the 'proper' way, and what we are doing is really using data-* as a selector, use |
My concern with using an HTML attribute is that when I see Seeing
|
(Sorry, timezones mean I'm a bit late to this so some of this has already been covered but here's my thoughts.) Whilst the The data attribute spec contains the following:
My, admittedly superficial, reading of this issue suggests to me that you are using them to "store custom data private to the page or application" and this data is "not intended for use by software that is independent of the site that uses the attributes". Can't think of a more textbook use case :-) If you want to be fully future friendly then you should also namespace your data attributes and this is specifically encouraged by the spec for "[a]uthors of libraries that are reused by many authors". This again sounds to me a lot like the situation here :-) |
Okay, after flip-flopping on all of these for a couple of days in my head, I'm putting a strong +1 for I also propose we change those shortcuts to use I also agree we should probably change it to I'd happily debate alternative names to hook, however, remember that an alternative has to be quite general. We use these on:
For me those various uses rule out, As to why not However, this is a "serious" open source project. To quote @decadecity from a conversation I had with him "[we] are asking people to trust [us] to make decisions for them, they should be able to see that you understand the consequences of that". Every time someone looks at/uses Yes If people really want to use |
Hm, what about "data-ctx" and/or "data-context"? |
After this whole debate, huge +1 for @latentflip with his whole explanation.
|
I read this entire thread thinking "Why not just use TL;DR: I like |
From thesaurus.com :) data-aim ...or simply 'data-role' However, as long as it follows html5 all names are quite acceptable, imho. :) |
As long as we're all bikeshedding: |
It's funny, I was contemplating this all last night and finally came to some peace about it in my head, philip's original data-hook suggestion just made sense to me. But, I kept seeing notifications about comments on this issue then was happy to discover @latentflip had reached the same conclusion.
Plus we'll make the change to support multiple space-separated hooks per element as @latentflip described.
I like I'm not entirely sure on Thanks everyone for your input. |
This thread is amazing. Thoughtful conversation, useful information, and no trolls. That's a rarity. |
Zeke wrote:
Amen to that. I wanted to +1 the data-* approach and point out a few more features of DOM and CSS that might make it even more attractive: HTMLElement.dataset APIel.setAttribute("data-js", "foo");
console.log(el.dataset.js); // "foo"
el.dataset.js = "bar";
console.log(el.getAttribute("data-js")); // "bar" YMMV wrt cross-browser support. More complex CSS attribute selectors.As latentflip mentioned above, Another interesting one is |
Closing this \o/ thanks everyone. |
Assigning certain role attribute values to some elements affects the way accessibility readers present your UI to the end user.
http://rawgit.com/w3c/aria-in-html/master/index.html#what-does-adding-a-role-do-to-the-native-semantics
It would be nice to at least mention this in the learn page, and hopefully even go into some best practices (if some can be determined)
The text was updated successfully, but these errors were encountered: