Created
October 7, 2016 17:03
-
-
Save peterkc/e59ba160d06f49123e69496f3845bcb5 to your computer and use it in GitHub Desktop.
input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {@see textbox role} | |
* {@link https://www.w3.org/TR/html-aria/} | |
* {@link https://www.w3.org/TR/wai-aria/roles#textbox} | |
* {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_textbox_role} | |
*/ | |
.directive('input', function(spAriaUtil) { | |
function link($scope, $element, attr) { | |
var role; | |
switch (attr['type']) { | |
case 'email': | |
case 'password': | |
case 'tel': | |
case 'text': | |
case 'url': | |
role = 'textbox'; | |
break; | |
case 'button': | |
case 'checkbox': | |
case 'radio': | |
role = attr['type']; | |
break; | |
case 'hidden': | |
$element.attr('aria-hidden', 'true'); | |
break; | |
case 'image': | |
case 'reset': | |
case 'submit': | |
role = 'button'; | |
break; | |
case 'number': | |
role = 'spinbutton'; | |
break; | |
case 'range': | |
role = 'slider'; | |
break; | |
case 'search': | |
role = 'searchbox'; | |
break; | |
} | |
if (spAriaUtil.g_accessibility && !_.isEmpty(role)) | |
spAriaUtil.link(role, false, 0)($scope, $element, attr); | |
} | |
return { | |
restrict : 'E', | |
link : link | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment