Invalid input types also default to text behavior (#822)
This commit is contained in:
@@ -343,38 +343,17 @@ function isTableRelatedElement(element) {
|
|||||||
|
|
||||||
function isInteractableInput(element) {
|
function isInteractableInput(element) {
|
||||||
const tagName = element.tagName.toLowerCase();
|
const tagName = element.tagName.toLowerCase();
|
||||||
const type = element.getAttribute("type") ?? "text"; // Default is text: https://www.w3schools.com/html/html_form_input_types.asp
|
|
||||||
if (tagName !== "input") {
|
if (tagName !== "input") {
|
||||||
// let other checks decide
|
// let other checks decide
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Browsers default to "text" when the type is not set or is invalid
|
||||||
if (type.toLowerCase().trim() === "text") {
|
// Here's the list of valid types: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types
|
||||||
return !isReadonlyElement(element);
|
// Examples of unrecognized types that we've seen and caused issues because we didn't mark them interactable:
|
||||||
}
|
// "city", "state", "zip", "country"
|
||||||
|
// That's the reason I (Kerem) removed the valid input types check
|
||||||
const clickableTypes = [
|
var type = element.getAttribute("type")?.toLowerCase().trim() ?? "text";
|
||||||
"button",
|
return !isReadonlyElement(element) && type !== "hidden";
|
||||||
"checkbox",
|
|
||||||
"date",
|
|
||||||
"datetime-local",
|
|
||||||
"email",
|
|
||||||
"file",
|
|
||||||
"image",
|
|
||||||
"month",
|
|
||||||
"number",
|
|
||||||
"password",
|
|
||||||
"radio",
|
|
||||||
"range",
|
|
||||||
"reset",
|
|
||||||
"search",
|
|
||||||
"submit",
|
|
||||||
"tel",
|
|
||||||
"time",
|
|
||||||
"url",
|
|
||||||
"week",
|
|
||||||
];
|
|
||||||
return clickableTypes.includes(type.toLowerCase().trim());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInteractable(element) {
|
function isInteractable(element) {
|
||||||
|
|||||||
Reference in New Issue
Block a user