Skip to content

Commit

Permalink
chore(docs): fix discord link
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Feb 9, 2024
1 parent 3fe62f7 commit 4c79036
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ We are building a rust based runner called [kayle_innate](./kayle_innate/) that

## Discord

If you want to chat about the project checkout our [Discord](https://discord.gg/ukmJcjQ5).
If you want to chat about the project checkout our [Discord][discord-url].

## About

Expand All @@ -260,4 +260,4 @@ One of the main goals was to have the audit run quickly since we noticed some of
Check the license file in the root of each project.

[discord-badge]: https://img.shields.io/discord/860982761137111040.svg?logo=discord
[discord-url]: https://discord.gg/ukmJcjQ5
[discord-url]: https://discord.gg/H82vceTBNu
81 changes: 76 additions & 5 deletions fast_htmlcs/HTMLCS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,22 @@ _global.HTMLCS = new (function () {
// See if the ruleset object is already included (eg. if minified).
const parts = _standard.split("/");
const part = parts[parts.length - 2];
const ruleSet = _getRuleset(part);

_registerStandard(_standard, part, callback, failCallback, options);
if (ruleSet) {
// Already included.
_registerStandard(_standard, part, callback, failCallback, options);
} else {
// TODO: remove _include script callback standard always included
_includeScript(
_standard,
function () {
// Script is included now register the standard.
_registerStandard(_standard, part, callback, failCallback, options);
},
failCallback
);
}
};

/**
Expand Down Expand Up @@ -450,6 +464,9 @@ _global.HTMLCS = new (function () {
// Already loaded.
if (sniffObj) {
cb();
} else {
// for browser usage at runtime non node.js
_includeScript(_getSniffPath(standard, sniff), cb, failCallback);
}
} else {
// Including a whole other standard.
Expand Down Expand Up @@ -493,6 +510,20 @@ _global.HTMLCS = new (function () {
}
};

/**
* Returns the path to the sniff file.
*
* @param {String} standard The name of the standard.
* @param {String} sniff The name of the sniff.
*
* @returns {String} The path to the JS file of the sniff.
*/
const _getSniffPath = (standard, sniff) => {
const parts = standard.split("/");
parts.pop();
return parts.join("/") + "/Sniffs/" + sniff.replace(/\./g, "/") + ".js";
};

/**
* Returns the path to a local standard.
*
Expand All @@ -515,10 +546,8 @@ _global.HTMLCS = new (function () {
const cstandard = _standards.has(standard) && _standards.get(standard); // standard should always exist
let name = "HTMLCS_";

name +=
((cstandard && cstandard.name) || "") +
"_Sniffs_" +
sniff.split(".").join("_");
name += ((cstandard && cstandard.name) || "") + "_Sniffs_";
name += sniff.split(".").join("_");

if (!_global[name]) {
return null;
Expand All @@ -539,4 +568,46 @@ _global.HTMLCS = new (function () {
*/
const _getMessageCode = (code) =>
_standard + "." + _currentSniff._name + "." + code;

/**
* Includes the specified JS file.
*
* @param {String} src The URL to the JS file.
* @param {Function} callback The function to call once the script is loaded.
*/
const _includeScript = (src, callback, failCallback) => {
const script = document.createElement("script");

script.onload = function () {
script.onload = null;
// @ts-ignore
script.onreadystatechange = null;
callback.call(this);
};

script.onerror = function () {
script.onload = null;
// @ts-ignore
script.onreadystatechange = null;
if (failCallback) {
failCallback.call(this);
}
};

// @ts-ignore
script.onreadystatechange = function () {
if (/^(complete|loaded)$/.test(this.readyState) === true) {
// @ts-ignore
script.onreadystatechange = null;
// @ts-ignore
script.onload();
}
};

script.src = src;

document.head
? document.head.appendChild(script)
: document.getElementsByTagName("head")[0].appendChild(script);
};
})();
2 changes: 1 addition & 1 deletion fast_htmlcs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fast_htmlcs",
"version": "0.0.70",
"version": "0.0.71",
"description": "A high performance fork of HTML_CodeSniffer.",
"license": "BSD-3-Clause",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion kayle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kayle",
"version": "0.8.7",
"version": "0.8.8",
"description": "Extremely fast and accurate accessibility engine built for any headless tool like playwright or puppeteer.",
"main": "./build/index.js",
"keywords": [
Expand Down

0 comments on commit 4c79036

Please sign in to comment.