kayle
Version:
Extremely fast and accurate accessibility engine built for any headless tool like playwright or puppeteer.
64 lines • 2.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.htmlcsLocales = exports.htmlcsRunner = void 0;
const run = async (options) => {
return new Promise((resolve, reject) => {
if (typeof window.define === "function" &&
window.define.amd &&
typeof window.require === "function") {
window.require(["htmlcs"], (htmlcs) => {
Object.keys(htmlcs).forEach((key) => {
window[key] = htmlcs[key];
});
window.HTMLCS = htmlcs.HTMLCS;
});
}
if (!(!options.rules ||
(options.rules && !options.rules.length) ||
options.standard === "Section508")) {
for (const rule of options.rules) {
if (window.HTMLCS_WCAG2AAA.sniffs.includes(rule)) {
window[`HTMLCS_${options.standard}`].sniffs[0].include.push(rule);
}
else {
console.error(`${rule} is not a valid WCAG 2.1 rule`);
}
}
}
window.HTMLCS.process(options.standard || "WCAG2AA", (options.rootElement &&
window.document.querySelector(options.rootElement)) ||
window.document, (error) => {
if (error) {
return reject(error);
}
resolve(window.HTMLCS.messages);
}, (error) => reject(error), options.language);
});
};
const htmlcsRunner = {
en: {
scripts: [require.resolve("fast_htmlcs/build/HTMLCS.js")],
run,
},
};
exports.htmlcsRunner = htmlcsRunner;
const htmlcsLocales = [
"ar",
"fr",
"es",
"it",
"ja",
"nl",
"pl",
"ko",
"zh_CN",
"zh_TW",
];
exports.htmlcsLocales = htmlcsLocales;
for (const lang of htmlcsLocales) {
htmlcsRunner[lang.replace("_", "-")] = {
scripts: [require.resolve(`fast_htmlcs/build/HTMLCS.${lang}.js`)],
run,
};
}
//# sourceMappingURL=htmlcs.js.map