Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(gates): an aria-* or data-* written on Button / IconButton is a finding

esengine0bc71eca4929
diff --git a/desktop b/desktop
index 30b6fec80..0ab016ab6 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit 30b6fec80d4a665e78c1f72da0a0d7a82b00f6e0
+Subproject commit 0ab016ab67d8ff3fb388d2d73f801167e532861f
diff --git a/tools/baselines/theme-drift.json b/tools/baselines/theme-drift.json
index 6c53b6ad4..8e917939c 100644
--- a/tools/baselines/theme-drift.json
+++ b/tools/baselines/theme-drift.json
@@ -16,7 +16,7 @@
"sequencer.css": 1,
"settings.css": 1,
"tilemap.css": 1,
- "tileset.css": 2,
+ "tileset.css": 1,
"viewport.css": 5,
"world.css": 1
},
@@ -26,7 +26,7 @@
"content.css": 7,
"controllers.css": 5,
"controls.css": 1,
- "events.css": 4,
+ "events.css": 3,
"flipbook.css": 3,
"inspector.css": 39,
"launcher.css": 3,
@@ -112,7 +112,6 @@
"components/TilemapPickerDialog.tsx": 1,
"components/Toaster.tsx": 1,
"components/Transport.tsx": 1,
- "events/EventBindingSection.tsx": 3,
"launcher/Launcher.tsx": 10,
"layout/ActivityBar.tsx": 1,
"layout/DockLayout.tsx": 3,
@@ -122,12 +121,12 @@
"layout/Toolbar.tsx": 6,
"layout/WindowControls.tsx": 3,
"panels/ContentBrowser.tsx": 5,
- "panels/ControllersPanel.tsx": 5,
- "panels/Details.tsx": 24,
- "panels/FlipbookEditor.tsx": 3,
+ "panels/ControllersPanel.tsx": 2,
+ "panels/Details.tsx": 23,
+ "panels/FlipbookEditor.tsx": 2,
"panels/HealthPanel.tsx": 1,
"panels/HistoryPanel.tsx": 5,
- "panels/inspector/componentDecorators.tsx": 11,
+ "panels/inspector/componentDecorators.tsx": 9,
"panels/inspector/controls.tsx": 15,
"panels/LightingPanel.tsx": 2,
"panels/Outliner.tsx": 1,
@@ -138,8 +137,8 @@
"panels/Sequencer.tsx": 7,
"panels/SpineDiagnosticsSection.tsx": 1,
"panels/SpinePreviewPane.tsx": 1,
- "panels/TilemapPainter.tsx": 11,
- "panels/TilesetEditor.tsx": 25,
+ "panels/TilemapPainter.tsx": 10,
+ "panels/TilesetEditor.tsx": 20,
"panels/UIWidgetsPanel.tsx": 1,
"panels/Viewport.tsx": 6,
"panels/WorldPanel.tsx": 3
diff --git a/tools/check-theme.mjs b/tools/check-theme.mjs
index a262c1881..08aa6dc52 100644
--- a/tools/check-theme.mjs
+++ b/tools/check-theme.mjs
@@ -461,6 +461,39 @@ const colourCode = colourLiteralInCodeByFile();
const fontSizes = rawFontSizeByFile();
const icons = iconScale();
const handRolled = handRolledByFile();
+/**
+ * `<Button>` and `<IconButton>` forward only the props they declare, and
+ * TypeScript does not check a hyphenated JSX name, so an `aria-*` or `data-*`
+ * written on one is dropped without a word — a disclosure that never says it is
+ * open. Their own props (`expanded`, `popup`, `ariaLabel`, `title`) carry these.
+ */
+/** The opening tag at `at`, read to its own `>`: an attribute's `() => x` does not end it. */
+const openingTag = (text, at) => {
+ let depth = 0;
+ for (let i = at + 1; i < text.length; i++) {
+ const c = text[i];
+ if (c === '{') depth += 1;
+ else if (c === '}') depth -= 1;
+ else if (c === '>' && depth === 0) return text.slice(at, i + 1);
+ }
+ return text.slice(at);
+};
+
+const droppedAttributes = () => {
+ const out = [];
+ for (const file of everyFile(SRC_DIR)) {
+ if (!file.endsWith('.tsx')) continue;
+ const text = readFileSync(file, 'utf8');
+ for (const m of text.matchAll(/<(Button|IconButton)\b/g)) {
+ const names = [...openingTag(text, m.index).matchAll(/(?<![\w-])((?:aria|data)-[a-z-]+)=/g)].map((a) => a[1]);
+ if (names.length === 0) continue;
+ const line = text.slice(0, m.index).split('\n').length;
+ out.push(`desktop/src/${path.relative(SRC_DIR, file).replaceAll(path.sep, '/')}:${line}: <${m[1]}> drops ${names.join(', ')} — use its own prop`);
+ }
+ }
+ return out;
+};
+for (const finding of droppedAttributes()) problems.push(finding);
for (const site of nativeTitles()) {
problems.push(`${site}: title= is the operating system's tooltip — use data-tip, `
+ 'and aria-label where it was the control\'s only name');