Skip to content

Commit

Permalink
update the common util #1974
Browse files Browse the repository at this point in the history
  • Loading branch information
shunguoy committed Sep 24, 2024
1 parent 570140b commit 8b54e0f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const input_label_exists: Rule = {
}

let POF = -1;
let textTypes = [
/** let textTypes = [
"text", "file", "password",
"checkbox", "radio",
"search", "tel", "url", "email", //HTML 5. Note: type = "hidden" doesn't require text
Expand All @@ -93,7 +93,10 @@ export const input_label_exists: Rule = {
]
let buttonTypes = [
"button", "reset", "submit"
]
]*/
let textTypes = CommonUtil.input_text_types;
let buttonTypes = CommonUtil.input_button_types;

let buttonTypesWithDefaults = ["reset", "submit"]; // 'submit' and 'reset' have visible defaults.
if (textTypes.indexOf(type) !== -1) { // If type is in the list
// Get only the non-hidden labels for elements, in the case that a label is hidden then it is a violation
Expand Down
12 changes: 12 additions & 0 deletions accessibility-checker-engine/src/v4/util/CommonUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ import { FragmentUtil } from "../../v2/checker/accessibility/util/fragment";

export class CommonUtil {

public static input_type_with_placeholder = ["text", "search", "tel", "url", "email", "password", "number"];
public static input_text_types = [
"text", "file", "password",
"checkbox", "radio",
"search", "tel", "url", "email", //HTML 5. Note: type = "hidden" doesn't require text
"date", "number", "range", //HTML 5. type = "image" is checked in g10.
"time", "color"
];
public static input_button_types = [
"button", "reset", "submit"
];

public static tabTagMap = {
"button": function (element): boolean {
return !element.hasAttribute("disabled");
Expand Down
7 changes: 7 additions & 0 deletions accessibility-checker-engine/src/v4/util/VisUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ export class VisUtil {
* Note: If either current node or any of the parent nodes are hidden then this
* function will return false (node is not visible).
*
* Note: nodes with CSS properties opacity:0 or filter:opacity(0%), or similar SVG mechanisms:
* They are not considered hidden. Text hidden with these methods can still be selected or copied,
* and user agents still expose it in their accessibility trees.
*
* Note: nodes hidden off screen or behind another object: they are not considered hidden.
* They are exposed in the accessibility tree and they can even name on-screen objects.
*
* @parm {element} node The node which should be checked if it is visible or not.
* @return {bool} false if the node is NOT visible, true otherwise
*
Expand Down

0 comments on commit 8b54e0f

Please sign in to comment.