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

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: updated Layout tests with expected ARIA attributes 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
52 */
53 UI.ARIAUtils.unsetExpanded = function(element) {
54 element.removeAttribute('aria-expanded');
55 };
56
57 /**
58 * @param {!Element} element
16 * @param {boolean} value 59 * @param {boolean} value
17 */ 60 */
18 UI.ARIAUtils.setSelected = function(element, value) { 61 UI.ARIAUtils.setSelected = function(element, value) {
19 // aria-selected behaves differently for false and undefined. 62 // aria-selected behaves differently for false and undefined.
20 // Often times undefined values are unintentionally typed as booleans. 63 // Often times undefined values are unintentionally typed as booleans.
21 // Use !! to make sure this is true or false. 64 // Use !! to make sure this is true or false.
22 element.setAttribute('aria-selected', !!value); 65 element.setAttribute('aria-selected', !!value);
23 }; 66 };
24 67
25 /** 68 /**
26 * @param {!Element} element 69 * @param {!Element} element
27 * @param {boolean} value 70 * @param {boolean} value
28 */ 71 */
29 UI.ARIAUtils.setPressed = function(element, value) { 72 UI.ARIAUtils.setPressed = function(element, value) {
30 // aria-pressed behaves differently for false and undefined. 73 // aria-pressed behaves differently for false and undefined.
31 // Often times undefined values are unintentionally typed as booleans. 74 // Often times undefined values are unintentionally typed as booleans.
32 // Use !! to make sure this is true or false. 75 // Use !! to make sure this is true or false.
33 element.setAttribute('aria-pressed', !!value); 76 element.setAttribute('aria-pressed', !!value);
34 }; 77 };
35 78
36 /** 79 /**
37 * @param {!Element} element 80 * @param {!Element} element
38 * @param {string} name 81 * @param {string} name
39 */ 82 */
40 UI.ARIAUtils.setAccessibleName = function(element, name) { 83 UI.ARIAUtils.setAccessibleName = function(element, name) {
41 element.setAttribute('aria-label', name); 84 element.setAttribute('aria-label', name);
42 }; 85 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698