[3.0] Reveal an inline spoiler when it is clicked - #9495
Merged
jdarwood007 merged 1 commit intoAug 11, 2026
Conversation
The content of an inline spoiler is hidden in the stylesheet and only a 'revealed' class brings it back, so the tag needs something listening for the click. That listener went out with 588d99d, which removed the handler and the two places that attached it, and nothing took its place - so clicking an inline spoiler has done nothing since. Listens on the document instead of binding each spoiler. The old code had to attach in two places and still missed any post that arrived after the page did, which is most of them: a preview, a quoted post, a personal message read in the popup. The span holds a button so assistive technology and the keyboard have something to press, and closest() answers for the button and the span alike. Spoilers written across several lines, or given a text parameter, are not affected - those render as a details element and never needed script. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Clicking an inline spoiler does nothing. The content stays hidden.
The tag renders as a span whose content is hidden in the stylesheet, and only a
revealedclass brings it back:Nothing adds that class.
588d99d63("Remove string evaluations") took out thetoggleSpoilerfunction and both places that attached it, and nothing replaced them — the wordrevealedno longer appears anywhere outside the minified build artifacts. It looks like collateral damage in a cleanup rather than a deliberate removal; the handler had been added on purpose five months earlier inf82d5e76c.Only one of the two spoiler forms is affected.
Spoiler1::validate()switches to adetailselement when the content spans several lines or atextparameter is given, and that form is plain HTML that never needed script. A short one-line[spoiler]…[/spoiler]gets the inline span, and that is the broken one — which is probably why this went unreported for a while.There is an odd side effect worth noting:
noscript.cssreveals the spoiler on:hover, so it currently behaves better with JavaScript disabled than enabled.This listens on the document rather than binding each spoiler. The removed code had to attach in two places — once at load and again after a preview — and still missed any post that arrived after the page did, which is most of them: a quoted post, a personal message read in the popup, a preview. Delegation covers all of those with no re-attachment. The span holds a button so that assistive technology and the keyboard have something to press, and
closest()answers for the button and the span alike, so both routes toggle the one element the CSS looks at.Tested against a real DOM (jsdom) using the markup
BBCodeParseractually emits: reveals on the button, on the span and on the text; toggles back; leaves the class on the span and not the button; ignores clicks elsewhere; and works on a spoiler inserted after load.Issues References (Fixes|Related|Closes)
Reported by a user on the community forum. Regression from
588d99d63.