Skip to content

Commit 47f422a

Browse files
committed
Auto-detect fragment mode inside audit()
Callers no longer need to call isHTMLFragment and pass componentMode — audit() handles it internally. componentMode can still be passed as an explicit override.
1 parent a97ce2f commit 47f422a

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

dist/audit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function ensureGlobals(window) {
2626
}
2727
function audit(html, options = {}) {
2828
const config = {
29-
componentMode: options.componentMode ?? false
29+
componentMode: options.componentMode ?? isHTMLFragment(html)
3030
};
3131
if (options.includeAAA)
3232
config.includeAAA = true;

dist/cli.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7766,11 +7766,11 @@ function ensureGlobals(window) {
77667766
globalsRegistered = true;
77677767
}
77687768
function audit(html, options = {}) {
7769-
const config = {};
7769+
const config = {
7770+
componentMode: options.componentMode ?? isHTMLFragment(html)
7771+
};
77707772
if (options.includeAAA)
77717773
config.includeAAA = true;
7772-
if (options.componentMode)
7773-
config.componentMode = true;
77747774
if (options.disabledRules?.length)
77757775
config.disabledRules = options.disabledRules;
77767776
Bn(config);
@@ -7868,7 +7868,6 @@ var main = defineCommand({
78687868
const disabledRules = args.disable ? args.disable.split(",").map((s2) => s2.trim()) : undefined;
78697869
const result = audit(html, {
78707870
includeAAA: args["include-aaa"],
7871-
componentMode: isHTMLFragment(html),
78727871
disabledRules
78737872
});
78747873
console.log(format(result, args.format));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@accesslint/cli",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/AccessLint/cli"

src/audit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function ensureGlobals(window: typeof globalThis): void {
3838

3939
export function audit(html: string, options: AuditOptions = {}): AuditResult {
4040
const config: ConfigureOptions = {
41-
componentMode: options.componentMode ?? false,
41+
componentMode: options.componentMode ?? isHTMLFragment(html),
4242
};
4343
if (options.includeAAA) config.includeAAA = true;
4444
if (options.disabledRules?.length) config.disabledRules = options.disabledRules;

src/cli.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
import { defineCommand, runMain } from "citty";
33
import { resolveInput } from "./input.js";
4-
import { audit, isHTMLFragment } from "./audit.js";
4+
import { audit } from "./audit.js";
55
import { format } from "./format.js";
66

77
const main = defineCommand({
@@ -42,7 +42,6 @@ const main = defineCommand({
4242

4343
const result = audit(html, {
4444
includeAAA: args["include-aaa"],
45-
componentMode: isHTMLFragment(html),
4645
disabledRules,
4746
});
4847

0 commit comments

Comments
 (0)