Skip to content

Commit

Permalink
XWIKI-21772: Admin section: make user directory pass webstandard tests (
Browse files Browse the repository at this point in the history
xwiki#2795)

* Fixed the input label validation to allow another standard HTML way to link the label to its in
  • Loading branch information
Sereza7 committed Feb 12, 2024
1 parent f82bc71 commit 695926e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&section=Rights
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&section=usersgroups.extensionrights
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&section=UserProfile
<!--/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=userdirectory
TODO https://jira.xwiki.org/browse/XWIKI-21772 -->
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=userdirectory
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=Registration
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=Invitation
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1160,12 +1160,16 @@ public void validateRpd13s1()
if (id != null) {
// Looking for the label associated to the input.
boolean hasLabel = false;
for (Element label : getElement(ELEM_BODY).getElementsByTag("label")) {
String labelTagName = "label";
for (Element label : getElement(ELEM_BODY).getElementsByTag(labelTagName)) {
if (id.equals(label.attr("for"))) {
hasLabel = true;
break;
}
}
// From MDN webdocs: Alternatively, you can nest the <input> directly inside the <label>,
// in which case the for and id attributes are not needed because the association is implicit
hasLabel = hasLabel || input.parent().tag().getName().equals(labelTagName);
assertTrue(Type.ERROR, message, hasLabel);
}
}
Expand Down

0 comments on commit 695926e

Please sign in to comment.