Skip to content
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

AccName algorithm doesn't account for specific roles and how these need to be treated differently when computing name from content #7

Open
accdc opened this issue Feb 21, 2018 · 2 comments
Assignees
Milestone

Comments

@accdc
Copy link
Contributor

accdc commented Feb 21, 2018

The following code block is an excerpt from the Naming Computation Prototype at
https://raw.githubusercontent.com/WhatSock/w3c-alternative-text-computation/8767d9a9250443ca0297acc4646411a13b3f24b1/docs/Sample%20JavaScript%20Recursion%20Algorithm/recursion.js

It reflects a discussion on the ARIA WG list regarding this topic referenced at
https://lists.w3.org/Archives/Public/public-aria/2017Jun/0057.html

This has a fundamental impact on the recursion algorithm, but it is not detailed within the spec, and it really should be.

These are rules that dictate when and how name from content should be computed, and for which roles they apply.

	var isException = function(node, refNode) {
		if (!refNode || !node || refNode.nodeType !== 1 || node.nodeType !== 1) {
			return false;
		}

		// Always include name from content when the referenced node matches list1, as well as when child nodes match those within list3
		var list1 = {
			roles: ['link', 'button', 'checkbox', 'option', 'radio', 'switch', 'tab', 'treeitem', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'cell', 'columnheader', 'rowheader', 'tooltip', 'heading'],
			tags: ['a', 'button', 'summary', 'input', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'menuitem', 'option', 'td', 'th']
		};

		// Never include name from content when current node matches list2
		var list2 = {
			roles: ['application', 'alert', 'log', 'marquee', 'timer', 'alertdialog', 'dialog', 'banner', 'complementary', 'form', 'main', 'navigation', 'region', 'search', 'article', 'document', 'feed', 'figure', 'img', 'math', 'toolbar', 'menu', 'menubar', 'grid', 'listbox', 'radiogroup', 'textbox', 'searchbox', 'spinbutton', 'scrollbar', 'slider', 'tablist', 'tabpanel', 'tree', 'treegrid', 'separator'],
			tags: ['article', 'aside', 'body', 'select', 'datalist', 'optgroup', 'dialog', 'figure', 'footer', 'form', 'header', 'hr', 'img', 'textarea', 'input', 'main', 'math', 'menu', 'nav', 'section']
		};

		// As an override of list2, conditionally include name from content if current node is focusable, or if the current node matches list3 while the referenced parent node matches list1.
		var list3 = {
			roles: ['combobox', 'term', 'definition', 'directory', 'list', 'group', 'note', 'status', 'table', 'rowgroup', 'row', 'contentinfo'],
			tags: ['dl', 'ul', 'ol', 'dd', 'details', 'output', 'table', 'thead', 'tbody', 'tfoot', 'tr']
		};

		var inList = function(node, list) {
			var role = node.getAttribute('role');
			var tag = node.nodeName.toLowerCase();
			return (
				list.roles.indexOf(role) >= 0 ||
				(!role && list2.tags.indexOf(tag) >= 0)
			);
		};

		if (inList(node, list2)) {
			return true;
		} else if (inList(node, list3)) {
			if (node === refNode) {
				return !isFocusable(node);
			} else {
				return !inList(refNode, list1);
			}
		} else {
			return false;
		}
	};
@mcking65 mcking65 added this to the 1.2 milestone Mar 8, 2018
@mcking65
Copy link

mcking65 commented Mar 8, 2018

Assigned to the 1.2 milestone because ...

While this issue is very clear and the desired results are clear, finding a good way to address this within the spec is a significant undertaking. The documentation of the algorithm is already overly complex and we have broad agreement that we need to find a way of making the algorithm more understandable. Attempting to resolve this issue with the current algorithm format could very likely result in greater obfuscation rather than more clarity.

@accdc
Copy link
Contributor Author

accdc commented Mar 9, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants