Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.3 (2026-11-12)

- `--browser` no longer waits for photos from other sites: they get a blank stand-in, since contrast and phone width don't depend on them. A slow or unreachable image host used to hold each page for up to 30 seconds in each color scheme, so a site with many linked photos (TagKit's templates and nonprofit starter) ran for minutes. Images with a `width` and `height` keep their size.

## 0.1.2 (2026-11-12)

Knows TagAction's and TagBrush.css's next releases.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ An agent that can't look at a screen can still run a command. TagCheck gives it

Exit codes: 0 clean, 1 problems, 2 bad usage.

With `--browser`, pages that link TagBrush.css (any build, including the scoped and Shadow DOM ones) or TagAction from jsDelivr are served the copy installed in your project, if there is one, so the check works offline and tests your version. A stylesheet or script that still doesn't load is reported (`not-loaded`), since contrast and widths measured without it mean little, and the summary (or `"browser": true` in the JSON) says the browser checks ran.
With `--browser`, pages that link TagBrush.css (any build, including the scoped and Shadow DOM ones) or TagAction from jsDelivr are served the copy installed in your project, if there is one, so the check works offline and tests your version. A stylesheet or script that still doesn't load is reported (`not-loaded`), since contrast and widths measured without it mean little, and the summary (or `"browser": true` in the JSON) says the browser checks ran. Photos from other sites aren't downloaded: they get a blank stand-in of the same size, so a slow image host doesn't slow the checks.

## Rules

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kovirlabs/tagcheck",
"version": "0.1.2",
"version": "0.1.3",
"description": "Find semantic and accessibility mistakes in HTML from the command line, CI, or an AI agent: missing alt text and labels, fake buttons, skipped headings, broken id references, contrast in light and dark mode, and sideways scrolling on phones. Part of the Tag family with TagBrush.css and TagAction.",
"keywords": [
"html",
Expand Down
5 changes: 5 additions & 0 deletions src/browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { pathToFileURL } from 'node:url';

export const PHONE_WIDTH = 360;
export const DESKTOP_WIDTH = 1280;
const BLANK_GIF = Buffer.from('R0lGODlhAQABAAAAACH5BAEAAAAALAAAAAABAAEAAAIBRAA7', 'base64');

async function loadPlaywright() {
const require = createRequire(join(process.cwd(), 'package.json'));
Expand Down Expand Up @@ -108,6 +109,10 @@ export async function checkInBrowser(files) {
}
for (const scheme of ['light', 'dark']) {
const page = await browser.newPage({ viewport: { width: DESKTOP_WIDTH, height: 900 }, colorScheme: scheme, reducedMotion: 'reduce' });
// Photos from other sites get a blank stand-in: neither check needs
// them, and a slow or unreachable image host would stall the page's
// load (and every page after it) for up to 30 seconds.
await page.route(/^https?:/, (route) => route.request().resourceType() === 'image' ? route.fulfill({ contentType: 'image/gif', body: BLANK_GIF }) : route.fallback());
for (const { pattern, path, contentType } of routes) await page.route(pattern, (route) => route.fulfill({ path, contentType }));
// A stylesheet or script that doesn't load (offline, a typo in the URL)
// would make every measurement below describe a different page.
Expand Down
9 changes: 8 additions & 1 deletion tests/check.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ test.describe('command line', () => {
test('--json prints a machine-readable report', () => {
const report = JSON.parse(run('tests/fixtures', '--json').stdout);
expect(report).toMatchObject({ tool: 'tagcheck', version: expect.any(String), errors: expect.any(Number), warnings: expect.any(Number) });
expect(report.files.map((f) => f.file)).toEqual(['tests/fixtures/bad.html', 'tests/fixtures/good.html', 'tests/fixtures/low-contrast.html', 'tests/fixtures/not-loaded.html', 'tests/fixtures/redirect.html']);
expect(report.files.map((f) => f.file)).toEqual(['tests/fixtures/bad.html', 'tests/fixtures/good.html', 'tests/fixtures/low-contrast.html', 'tests/fixtures/not-loaded.html', 'tests/fixtures/redirect.html', 'tests/fixtures/remote-image.html']);
});

test('--rules lists every rule', () => {
Expand Down Expand Up @@ -184,6 +184,13 @@ test.describe('--browser', () => {
expect(served('https://cdn.jsdelivr.net/npm/tagaction@0/tagaction.min.js')).toBe('tagaction.js');
});

test('does not wait for photos from other sites', async () => {
const started = Date.now();
const report = await checkFiles(['tests/fixtures/remote-image.html'], { browser: true });
expect(report.files[0].problems).toEqual([]);
expect(Date.now() - started).toBeLessThan(10000); // a stalled image held each page for 30 seconds
});

test('the report says whether the browser checks ran', async () => {
expect((await checkFiles(['tests/fixtures/good.html'])).browser).toBe(false);
});
Expand Down
17 changes: 17 additions & 0 deletions tests/fixtures/remote-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A photo from a slow host</title>
<style>img { max-width: 100%; height: auto; }</style>
</head>
<body>
<main>
<h1>A photo from a slow host</h1>
<!-- 10.255.255.1 never answers, like an image host that's down or slow. -->
<img src="http://10.255.255.1/photo.jpg" alt="A bowl of strawberries" width="600" height="450">
<p>The browser checks shouldn't wait for this photo.</p>
</main>
</body>
</html>
Loading