Skip to content

Commit 695926e

Browse files
committed
XWIKI-21772: Admin section: make user directory pass webstandard tests (xwiki#2795)
* Fixed the input label validation to allow another standard HTML way to link the label to its in
1 parent f82bc71 commit 695926e

File tree

2 files changed

+6
-3
lines changed
  • xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-test
  • xwiki-platform-tools/xwiki-platform-tool-standards-validator/src/main/java/org/xwiki/validator

2 files changed

+6
-3
lines changed

xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-test/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@
249249
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&section=Rights
250250
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&section=usersgroups.extensionrights
251251
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&section=UserProfile
252-
<!--/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=userdirectory
253-
TODO https://jira.xwiki.org/browse/XWIKI-21772 -->
252+
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=userdirectory
254253
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=Registration
255254
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=Invitation
256255
/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin&amp;section=Authentication

xwiki-platform-tools/xwiki-platform-tool-standards-validator/src/main/java/org/xwiki/validator/HTML5DutchWebGuidelinesValidator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,12 +1160,16 @@ public void validateRpd13s1()
11601160
if (id != null) {
11611161
// Looking for the label associated to the input.
11621162
boolean hasLabel = false;
1163-
for (Element label : getElement(ELEM_BODY).getElementsByTag("label")) {
1163+
String labelTagName = "label";
1164+
for (Element label : getElement(ELEM_BODY).getElementsByTag(labelTagName)) {
11641165
if (id.equals(label.attr("for"))) {
11651166
hasLabel = true;
11661167
break;
11671168
}
11681169
}
1170+
// From MDN webdocs: Alternatively, you can nest the <input> directly inside the <label>,
1171+
// in which case the for and id attributes are not needed because the association is implicit
1172+
hasLabel = hasLabel || input.parent().tag().getName().equals(labelTagName);
11691173
assertTrue(Type.ERROR, message, hasLabel);
11701174
}
11711175
}

0 commit comments

Comments
 (0)