Skip to content

Commit a206c7f

Browse files
authored
Resolve remaning build warnings and prevent future instances (#4201)
Resolves #3922 This PR resolves 2 warnings that have been in the Eleventy build since its introduction, then switches those warnings to errors to prevent further instances from being introduced. ## Fixes - Two sections with the same ID in F61 - Redundant Success Criteria section in 2.5 Input Modalities (along with some other edits to make this file consistent with other Guideline pages) None of these fixes cause changes to output other than whitespace (because the build system was previously auto-fixing these cases). ## Preventive measures The following will now fail the build (and PR checks): - Presence of the same `id` on multiple `section` elements within the same page - Presence of Success Criteria section (which is auto-generated)
1 parent ce09deb commit a206c7f

File tree

3 files changed

+21
-57
lines changed

3 files changed

+21
-57
lines changed

11ty/CustomLiquid.ts

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -203,40 +203,20 @@ export class CustomLiquid extends Liquid {
203203
.after(generateIncludes("techniques/about"))
204204
.replaceWith(generateIncludes("techniques/h1"));
205205

206-
const sectionCounts: Record<string, number> = {};
207-
let hasDuplicates = false;
206+
const detectedSections: Record<string, true> = {};
208207
$("body > section[id]").each((_, el) => {
209208
const id = el.attribs.id.toLowerCase();
210209
// Fix non-lowercase top-level section IDs (e.g. H99)
211210
el.attribs.id = id;
212-
// Track duplicate sections, to be processed next
213-
if (id in sectionCounts) {
214-
hasDuplicates = true;
215-
sectionCounts[id]++;
211+
// Fail on duplicate sections
212+
if (id in detectedSections) {
213+
console.error(`${filepath}: Multiple sections with id="${id}" found.`);
214+
throw new Error("Please resolve duplicate section IDs.");
216215
} else {
217-
sectionCounts[id] = 1;
216+
detectedSections[id] = true;
218217
}
219218
});
220219

221-
// Avoid loop altogether in majority of (correct) cases
222-
if (hasDuplicates) {
223-
for (const [id, count] of Object.entries(sectionCounts)) {
224-
if (count === 1) continue;
225-
console.warn(
226-
`${filepath}: Merging duplicate ${id} sections; please fix this in the source file.`
227-
);
228-
const $sections = $(`section[id='${id}']`);
229-
const $first = $sections.first();
230-
$sections.each((i, el) => {
231-
if (i === 0) return;
232-
const $el = $(el);
233-
$el.find("> h2:first-child").remove();
234-
$first.append($el.contents());
235-
$el.remove();
236-
});
237-
}
238-
}
239-
240220
$("section#resources h2").after(generateIncludes("techniques/intro/resources"));
241221
$("section#examples section.example").each((i, el) => {
242222
const $el = $(el);
@@ -268,13 +248,11 @@ export class CustomLiquid extends Liquid {
268248

269249
// Remove spurious copy-pasted content in 2.5.3 that doesn't belong there
270250
if ($("section#benefits").length > 1) $("section#benefits").first().remove();
271-
// Some pages nest Benefits inside Intent; XSLT always pulls it back out
272-
$("section#intent section#benefits")
273-
.insertAfter("section#intent")
274-
.find("h3:first-child")
275-
.each((_, el) => {
276-
el.tagName = "h2";
277-
});
251+
// Prevent pages from nesting Benefits inside Intent (old issue that has been fixed)
252+
if ($("section#intent section#benefits").length) {
253+
console.error(`${filepath}: Benefits section should not be nested inside Intent.`);
254+
throw new Error("Incorrectly-nested Benefits section found: please resolve.");
255+
}
278256

279257
// XSLT orders resources then techniques last, opposite of source files
280258
$("body")
@@ -291,15 +269,14 @@ export class CustomLiquid extends Liquid {
291269
generateIncludes("understanding/intro/sufficient-situation")
292270
);
293271
}
294-
// success-criteria section should be auto-generated;
295-
// remove any handwritten ones (e.g. Input Modalities)
296-
const $successCriteria = $("section#success-criteria");
297-
if ($successCriteria.length) {
298-
console.warn(
299-
`${filepath}: success-criteria section will be replaced with ` +
300-
"generated version; please remove this from the source file."
272+
273+
// Disallow handwritten success-criteria section (should be auto-generated)
274+
if ($("section#success-criteria").length) {
275+
console.error(
276+
`${filepath}: success-criteria section will be auto-generated; ` +
277+
"please remove this from the source file."
301278
);
302-
$successCriteria.remove();
279+
throw new Error("Please remove success-criteria section from guideline pages.");
303280
}
304281
// success-criteria template only renders content for guideline (not SC) pages
305282
$("body").append(generateIncludes("understanding/success-criteria"));

techniques/failures/F61.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@

4141
<li>If checks #3 and #4 are true, then this failure condition applies and the content fails this Success Criterionli>
4242
ul>
4343
section>
44-
section><section id="tests"><h2>Testsh2>
4544
<section class="procedure"><h3>Procedureh3>
4645
<ol>
4746
<li>Measure or estimate the amount of time that the average user spends on the page.li>

understanding/21/input-modalities.html

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,17 @@
33
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
44
<head>
55
<meta charset="UTF-8"/>
6-
<title>Understanding Guideline 2.5 | Understanding WCAG 2.1title>
6+
<title>Understanding Input Modalitiestitle>
77
<link rel="stylesheet" type="text/css" href="../../css/sources.css" class="remove"/>
88
head>
99
<body>
10-
<h1>Pointer Accessible:<br/>
11-
Understanding Guideline 2.1
12-
h1>
10+
<h1>Understanding Input Modalitiesh1>
1311
<section id="intent">
14-
<h2>Intent of Guideline 2.5h2>
12+
<h2>Intent of Input Modalitiesh2>
1513
<p>All functionality should be accessible via pointer input devices, for example, via a mouse pointer, a finger interacting with a touch screen, an electronic pencil/stylus, or a laser pointer.p>
1614
<p>People operating pointer input devices may not be able to carry out timed or complex gestures. Examples are drag-and-drop gestures and on touch screens, swiping gestures, split taps, or long presses. This Guideline does not discourage the provision of complex and timed gestures by authors. However, where they are used, an alternative method of input should be provided to enable users with motor impairments to interact with content via single untimed pointer gestures.p>
1715
<p>Often, people use devices that offer several input methods, for example, mouse input, touch input, keyboard input, and speech input. These should be supported concurrently as users may at any time swich preferred input methods due to situational circumstances, for example, the availability of a flat support for mouse operation, or situational impediments through motion or changes of ambient light.p>
1816
<p>A common requirement for pointer interaction is the ability of users to position the pointer over the target. With touch input, the pointer (the finger) is larger and less precise than a mouse cursor. For people with motor impairments, a larger target makes it easier to successfully position the pointer and activate the target.p>
1917
section>
20-
21-
<section id="success-criteria">
22-
<h2>Success Criteria for this Guidelineh2>
23-
<ul>
24-
<li><a href="pointer-gestures.html">Understanding Success Criterion 2.5.1 [Pointer Gestures]a>li>
25-
<li><a href="concurrent-input-mechanisms.html">Understanding Success Criterion 2.5.2 [Concurrent Input Mechanisms]a>li>
26-
<li><a href="target-size.html">Understanding Success Criterion 2.5.3 [Target Size]a>li>
27-
<li><a href="target-size-no-exception.html">Understanding Success Criterion 2.5.4 [Target Size (No Exception)]a>li>
28-
ul>
29-
section>
3018
body>
3119
html>

0 commit comments

Comments
 (0)