Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/ARIAUtils.js

Issue 2671203002: DevTools: Added ARIA roles & states to treeoutline (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 UI.ARIAUtils = {}; 5 UI.ARIAUtils = {};
6 6
7 /** 7 /**
8 * @param {!Element} element 8 * @param {!Element} element
9 */ 9 */
10 UI.ARIAUtils.markAsGroup = function(element) {
11 element.setAttribute('role', 'group');
12 };
13
14 /**
15 * @param {!Element} element
16 */
10 UI.ARIAUtils.markAsTab = function(element) { 17 UI.ARIAUtils.markAsTab = function(element) {
11 element.setAttribute('role', 'tab'); 18 element.setAttribute('role', 'tab');
12 }; 19 };
13 20
14 /** 21 /**
15 * @param {!Element} element 22 * @param {!Element} element
23 */
24 UI.ARIAUtils.markAsTree = function(element) {
25 element.setAttribute('role', 'tree');
26 };
27
28 /**
29 * @param {!Element} element
30 */
31 UI.ARIAUtils.markAsTreeitem = function(element) {
32 element.setAttribute('role', 'treeitem');
33 };
34
35 /**
36 * @param {!Element} element
37 */
38 UI.ARIAUtils.markAsPresentation = function(element) {
39 element.setAttribute('role', 'presentation');
40 };
41
42 /**
43 * @param {!Element} element
44 * @param {boolean} value
45 */
46 UI.ARIAUtils.setExpanded = function(element, value) {
47 element.setAttribute('aria-expanded', !!value);
48 };
49
50 /**
51 * @param {!Element} element
16 * @param {boolean} value 52 * @param {boolean} value
17 */ 53 */
18 UI.ARIAUtils.setSelected = function(element, value) { 54 UI.ARIAUtils.setSelected = function(element, value) {
19 // aria-selected behaves differently for false and undefined. 55 // aria-selected behaves differently for false and undefined.
20 // Often times undefined values are unintentionally typed as booleans. 56 // Often times undefined values are unintentionally typed as booleans.
21 // Use !! to make sure this is true or false. 57 // Use !! to make sure this is true or false.
22 element.setAttribute('aria-selected', !!value); 58 element.setAttribute('aria-selected', !!value);
23 }; 59 };
24 60
61
aboxhall 2017/02/06 05:06:26 Extra blank line.
hhillen 2017/02/09 02:18:41 Done
25 /** 62 /**
26 * @param {!Element} element 63 * @param {!Element} element
27 * @param {boolean} value 64 * @param {boolean} value
28 */ 65 */
29 UI.ARIAUtils.setPressed = function(element, value) { 66 UI.ARIAUtils.setPressed = function(element, value) {
30 // aria-pressed behaves differently for false and undefined. 67 // aria-pressed behaves differently for false and undefined.
31 // Often times undefined values are unintentionally typed as booleans. 68 // Often times undefined values are unintentionally typed as booleans.
32 // Use !! to make sure this is true or false. 69 // Use !! to make sure this is true or false.
33 element.setAttribute('aria-pressed', !!value); 70 element.setAttribute('aria-pressed', !!value);
34 }; 71 };
35 72
36 /** 73 /**
37 * @param {!Element} element 74 * @param {!Element} element
38 * @param {string} name 75 * @param {string} name
39 */ 76 */
40 UI.ARIAUtils.setAccessibleName = function(element, name) { 77 UI.ARIAUtils.setAccessibleName = function(element, name) {
41 element.setAttribute('aria-label', name); 78 element.setAttribute('aria-label', name);
42 }; 79 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698