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

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

Issue 2655393003: DevTools: Introduce ARIAUtils (Closed)
Patch Set: setAccessibleName in InspectorView Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/ARIAUtils.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/ARIAUtils.js b/third_party/WebKit/Source/devtools/front_end/ui/ARIAUtils.js
new file mode 100644
index 0000000000000000000000000000000000000000..94472e37bcbfe74e244f9f5d47aaeb6a80c1866a
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/ui/ARIAUtils.js
@@ -0,0 +1,42 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+UI.ARIAUtils = {};
+
+/**
+ * @param {!Element} element
+ */
+UI.ARIAUtils.markAsTab = function(element) {
+ element.setAttribute('role', 'tab');
+};
+
+/**
+ * @param {!Element} element
+ * @param {boolean} value
+ */
+UI.ARIAUtils.setSelected = function(element, value) {
+ // aria-selected behaves differently for false and undefined.
+ // Often times undefined values are unintentionally typed as booleans.
+ // Use !! to make sure this is true or false.
+ element.setAttribute('aria-selected', !!value);
+};
+
+/**
+ * @param {!Element} element
+ * @param {boolean} value
+ */
+UI.ARIAUtils.setPressed = function(element, value) {
+ // aria-pressed behaves differently for false and undefined.
+ // Often times undefined values are unintentionally typed as booleans.
+ // Use !! to make sure this is true or false.
+ element.setAttribute('aria-pressed', !!value);
+};
+
+/**
+ * @param {!Element} element
+ * @param {string} name
+ */
+UI.ARIAUtils.setAccessibleName = function(element, name) {
+ element.setAttribute('aria-label', name);
+};

Powered by Google App Engine
This is Rietveld 408576698