Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SONARHTML-198 Create rule S6852: Elements with an interactive role should support focus #284

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

yassin-kammoun-sonarsource
Copy link
Contributor

No description provided.

@yassin-kammoun-sonarsource yassin-kammoun-sonarsource force-pushed the SONARHTML-198 branch 4 times, most recently from 75da7cb to 7968028 Compare February 22, 2024 12:06
Comment on lines 72 to 101
private static boolean isHTMLTag(TagNode element) {
return KNOWN_HTML_TAGS.stream().anyMatch(tag -> tag.equalsIgnoreCase(element.getNodeName()));
}

private static boolean hasInteractiveProps(TagNode element) {
return INTERACTIVE_PROPS.stream().anyMatch(prop -> {
var attr = element.getAttribute(prop);
return attr != null && !attr.isEmpty();
});
}

private static boolean hasInteractiveRole(TagNode element) {
return INTERACTIVE_ROLES.stream().anyMatch(role -> role.equalsIgnoreCase(element.getAttribute("role")));
}

private static boolean isInteractiveElement(TagNode element) {
return INTERACTIVE_ELEMENTS.stream().anyMatch(tag -> tag.equalsIgnoreCase(element.getNodeName()));
}

private static boolean isNoninteractiveElement(TagNode element) {
return NON_INTERACTIVE_ELEMENTS.stream().anyMatch(tag -> tag.equalsIgnoreCase(element.getNodeName()));
}

private static boolean hasPresentationRole(TagNode element) {
return PRESENTATION_ROLES.stream().anyMatch(role -> role.equalsIgnoreCase(element.getAttribute("role")));
}

private static boolean hasNoninteractiveRole(TagNode element) {
return NON_INTERACTIVE_ROLES.stream().anyMatch(role -> role.equalsIgnoreCase(element.getAttribute("role")));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you refactor this to use the methods from HtmlConstants.java, and move the new ones there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@ilia-kebets-sonarsource ilia-kebets-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small refactoring suggestion, otherwise LGTM

@yassin-kammoun-sonarsource yassin-kammoun-sonarsource merged commit cd1a7dd into master Feb 22, 2024
8 checks passed
@yassin-kammoun-sonarsource yassin-kammoun-sonarsource deleted the SONARHTML-198 branch February 22, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants