-
-
+
The code in this example is not intended for production environments.
@@ -89,7 +88,6 @@ if (enableSidebar) document.body.classList.add('has-sidebar');
-
diff --git a/ARIA/apg/shared/templates/example-usage-warning.html b/ARIA/apg/shared/templates/example-usage-warning.html
index 3d5b202ab..32ae12c46 100644
--- a/ARIA/apg/shared/templates/example-usage-warning.html
+++ b/ARIA/apg/shared/templates/example-usage-warning.html
@@ -3,6 +3,7 @@
Support Notice (Template)
+
The code in this example is not intended for production environments.
diff --git a/scripts/pre-build/library/transformExample.js b/scripts/pre-build/library/transformExample.js
index 62c9143b5..2057b1864 100644
--- a/scripts/pre-build/library/transformExample.js
+++ b/scripts/pre-build/library/transformExample.js
@@ -1,25 +1,25 @@
-const fs = require("fs/promises");
-const path = require("path");
-const { exec } = require("child_process");
-const { parse: parseHtml } = require("node-html-parser");
-const { format } = require("date-fns");
-const formatForJekyll = require("./formatForJekyll");
-const { rewriteSourcePath, sourceRoot } = require("./rewritePath");
-const rewriteElementPaths = require("./rewriteElementPaths");
-const removeDuplicateMainTag = require("./removeDuplicateMainTag");
-const wrapTablesWithResponsiveDiv = require("./wrapTablesWithResponsiveDiv");
-const removeConflictingCss = require("./removeConflictingCss");
+const fs = require('fs/promises');
+const path = require('path');
+const { exec } = require('child_process');
+const { parse: parseHtml } = require('node-html-parser');
+const { format } = require('date-fns');
+const formatForJekyll = require('./formatForJekyll');
+const { rewriteSourcePath, sourceRoot } = require('./rewritePath');
+const rewriteElementPaths = require('./rewriteElementPaths');
+const removeDuplicateMainTag = require('./removeDuplicateMainTag');
+const wrapTablesWithResponsiveDiv = require('./wrapTablesWithResponsiveDiv');
+const removeConflictingCss = require('./removeConflictingCss');
const loadNotice = async () => {
const noticePath = path.resolve(
sourceRoot,
- "content/shared/templates/example-usage-warning.html"
+ 'content/shared/templates/example-usage-warning.html'
);
- const noticeContent = await fs.readFile(noticePath, { encoding: "utf8" });
+ const noticeContent = await fs.readFile(noticePath, { encoding: 'utf8' });
const html = parseHtml(noticeContent);
return () => {
- return html.querySelector("body").innerHTML;
+ return html.querySelector('body').innerHTML;
};
};
@@ -37,7 +37,7 @@ const getLastModifiedDate = async (exampleFilePath) => {
});
let dateFormatted;
try {
- dateFormatted = format(new Date(output), "d MMMM y");
+ dateFormatted = format(new Date(output), 'd MMMM y');
} catch (error) {
console.error(
`Failed to extract a last-modified date for the file "${exampleFilePath}"`
@@ -51,8 +51,8 @@ const transformExample = async (sourcePath, sourceContents) => {
const { sitePath, githubPath } = rewriteSourcePath(sourcePath);
const html = parseHtml(sourceContents);
- const title = html.querySelector("h1").innerHTML;
- html.querySelector("h1").remove();
+ const title = html.querySelector('h1').innerHTML;
+ html.querySelector('h1').remove();
const slug = sitePath.match(/patterns\/([^/]+)\//)?.[1];
@@ -61,23 +61,16 @@ const transformExample = async (sourcePath, sourceContents) => {
src="{{ '/content-images/wai-aria-practices/img/${slug}.svg' | relative_url }}"
class="example-page-example-icon"
/>`;
- if (html.querySelector(".advisement")) {
- html.querySelector(".advisement").insertAdjacentHTML("afterend", img);
+ if (html.querySelector('.advisement')) {
+ html.querySelector('.advisement').insertAdjacentHTML('afterend', img);
} else {
- html.querySelector("h2").insertAdjacentHTML("afterend", img);
+ html.querySelector('h2').insertAdjacentHTML('afterend', img);
}
removeConflictingCss(html);
const getNotice = await loadedNotice;
- const notice = getNotice();
- html.querySelector("body").insertAdjacentHTML(
- "afterbegin",
- `
-
- ${notice}
- `
- );
+ html.querySelector('body').insertAdjacentHTML('afterbegin', getNotice());
const lastModifiedDateFormatted = await getLastModifiedDate(sourcePath);
@@ -86,11 +79,11 @@ const transformExample = async (sourcePath, sourceContents) => {
const relatedLinksElement = html.querySelector(
'[aria-label="Related Links"]'
);
- const allRelatedLinks = relatedLinksElement.querySelectorAll("> ul > li > a");
+ const allRelatedLinks = relatedLinksElement.querySelectorAll('> ul > li > a');
const relatedIssuesLinkElement = allRelatedLinks.find(
- (link) => link.textContent.trim().toLowerCase() === "related issues"
+ (link) => link.textContent.trim().toLowerCase() === 'related issues'
);
- relatedIssuesLinkElement.textContent = "View issues related to this example";
+ relatedIssuesLinkElement.textContent = 'View issues related to this example';
const relatedIssuesLink = relatedIssuesLinkElement.outerHTML;
relatedLinksElement.remove();
@@ -99,10 +92,10 @@ const transformExample = async (sourcePath, sourceContents) => {
sitePath,
githubPath,
content: removeDuplicateMainTag(
- wrapTablesWithResponsiveDiv(html.querySelector("body").innerHTML)
+ wrapTablesWithResponsiveDiv(html.querySelector('body').innerHTML)
),
enableSidebar: true,
- head: html.querySelector("head").innerHTML,
+ head: html.querySelector('head').innerHTML,
footer: `