Skip to content

Commit

Permalink
Merge pull request #1778 from IBMa/dev-208
Browse files Browse the repository at this point in the history
fixrule(`fieldset_legend_valid`) ignore the rule if the fieldset element is hidden from an AT
  • Loading branch information
ErickRenteria authored Jan 10, 2024
2 parents 853bfd0 + ac4569b commit 837beb9
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import { Rule, RuleResult, RuleFail, RuleContext, RulePass, RuleContextHierarchy } from "../api/IRule";
import { eRulePolicy, eToolkitLevel } from "../api/IRule";
import { RPTUtil } from "../../v2/checker/accessibility/util/legacy";
import { VisUtil } from "../../v2/dom/VisUtil";

export let fieldset_legend_valid: Rule = {
id: "fieldset_legend_valid",
Expand Down Expand Up @@ -52,6 +53,10 @@ export let fieldset_legend_valid: Rule = {
act: [],
run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): RuleResult | RuleResult[] => {
const ruleContext = context["dom"].node as Element;
//skip if the fieldset is hidden or disabled
if (VisUtil.isNodeHiddenFromAT(ruleContext) || RPTUtil.isNodeDisabled(ruleContext))
return null;

// In the case a legend is hidden, we should still trigger a violations for this
let legends = RPTUtil.getChildByTagHidden(ruleContext, "legend", true, false);
if (legends.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!--
/******************************************************************************
Copyright:: 2020- IBM, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*****************************************************************************/
-->

<html lang="en">

<head>
<title>RPT Test Suite</title>
</head>

<body>

<a href="#navskip">skip to main content</a>


<h2>Test case: FieldSet-hasEmptyLegend.html</h2>



<!-- ################################################################### -->


<h3>Input type Tests</h3>


<ul>
<li>Test - fieldset is hidden or AT hidden</li>
</ul>

<form action="..." method="post" >
<fieldset aria-hidden="true">
<label for="fn1">First Name</label>
<input type="text" name="firstname" id="fn1" value="enter first name" title="enter first name">

<label for="ln1">Last Name</label>
<input type="text" name="lastname" id="ln1" value="enter last name" title="enter last name">
</fieldset>
<fieldset hidden>
<label for="fn11">First Name</label>
<input type="number" name="ssn" id="fn11" value="enter SSN" title="enter SSN">

<label for="ln11">Last Name</label>
<input type="number" name="phone" id="ln11" value="enter phone number" title="enter phone number">

</fieldset>
<button type="submit">Submit</button>
</form>

<a name="navskip"></a>


<script>
UnitTest = {
ruleIds: ["fieldset_legend_valid"],
results: [

]
};
</script>
</body>
</html>

0 comments on commit 837beb9

Please sign in to comment.