Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

fix: the empty-notes rule goes by what the script toggles, so a note wrapped in another element still shows

matin014853089dff
diff --git a/assets/css/demo-page.css b/assets/css/demo-page.css
index e72d6b5c..8cdd553a 100644
--- a/assets/css/demo-page.css
+++ b/assets/css/demo-page.css
@@ -108,8 +108,9 @@ body.hb [hidden]{display:none!important}
.hb-page .seg.hb-modes{gap:6px}
/* The empty box is the live region that makes a screen reader read each note out loud, so it stays on the page: display:none would
take it out of the accessibility tree, and the first note might not be announced. It is hidden to the eye and taken out of the
- flow instead, so it takes no room and adds no gap. */
-.hb-mode-notes:not(:has(> p:not([hidden]))){position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
+ flow instead, so it takes no room and adds no gap. It counts as empty until a note is un-hidden: any element with data-hb-for,
+ wherever it sits in the box, because that is what the script toggles. */
+.hb-mode-notes:not(:has([data-hb-for]:not([hidden]))){position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.hb-mode-notes p{margin:0;max-width:72ch;font:400 15px/1.55 var(--hb-font);color:var(--hb-dim)}
.hb-mode-notes a{color:var(--hb-ink);text-decoration:underline;text-underline-offset:3px}
diff --git a/tests/pages.test.js b/tests/pages.test.js
index c09ede0a..0df186fb 100644
--- a/tests/pages.test.js
+++ b/tests/pages.test.js
@@ -537,8 +537,9 @@ test('the shared stylesheet draws the mode switch beside the Watch heading from
'.hb-lesson-next', '.hb-lesson-all', '.hb-why p', '.hb-seen']) assert.ok(has(sel), sel);
// The empty box is the aria-live region that makes a screen reader read each note out, so it must stay rendered: display:none
// would take it out of the accessibility tree, and the first note shown might not be announced. It is hidden to the eye and taken
- // out of the flow instead, which takes no room and adds no gap.
- const emptyNotes = rules.filter(r => r.selector === '.hb-mode-notes:not(:has(> p:not([hidden])))');
+ // out of the flow instead, which takes no room and adds no gap. The box counts as empty until a note is un-hidden, and a note is
+ // whatever element has data-hb-for (the script un-hides those), wherever it sits in the box.
+ const emptyNotes = rules.filter(r => r.selector === '.hb-mode-notes:not(:has([data-hb-for]:not([hidden])))');
assert.ok(emptyNotes.some(r => /(^|;)\s*position:\s*absolute\s*(;|$)/.test(r.body) && /(^|;)\s*clip-path:\s*inset\(50%\)\s*(;|$)/.test(r.body)),
'an empty notes box takes no room: it is taken out of the flow and clipped away');
assert.ok(!emptyNotes.some(r => /(^|;)\s*display:\s*none\s*(;|$)/.test(r.body)),