Repository navigation
Drop jQuery: convert theme scripts to vanilla JS - #2777
Merged
Merged
Conversation
- Guards the jQuery-removal conversions: asserts fixture pages load with zero uncaught exceptions or console errors, which no existing suite (markup goldens, visual shots) can see - Rides the visual-suite job: lives in tests/visual/ for its Puppeteer plumbing and CI browser install; no workflow changes - Red-proven: with the jQuery script tag stubbed out, every page visit fails with "jQuery is not defined"; a collector self-test and an executed-visits floor keep green meaningful
- Replaces the jQuery-delegated keypress handler with document-level keydown delegation via closest() (keypress is deprecated); no DOM-ready wrapper needed for document-level delegation - Encodes the query with encodeURIComponent: previously a query containing & or # silently truncated the q param - Extends the js-runtime net: the gcs-search fixture variant arms this handler (the prior default variant only parsed the bundle), and a desktop-viewport Enter-navigation probe pins the behavior (verified green pre-conversion too)
- Replaces the jQuery replaceWith loop with querySelectorAll + Element.replaceWith; textContent keeps the text handling identical - Adds diagram behavior probes to the js-runtime net (markmap, plantuml, mermaid: rendered SVG or generated img in the DOM), verified green pre-conversion
- Replaces the jQuery replaceWith loop with querySelectorAll + Element.replaceWith; svg mode creates the loader element via createElementNS so external-svg-loader still sees a real SVG-namespace svg[data-src] - Scopes the encoder helpers' accidentally-global variables (r, i, c1..c4) with let/const - Drops the dead needPlantuml flag - Extends the js-runtime net: svg-mode fixture coverage (img mode was already probed) with a namespace assertion, green pre-conversion
- Drops the jQuery IIFE wrapper: presence checks become querySelector, and the dark-theme sniff reads documentElement.dataset directly (both probed by the existing mermaid SVG test)
- Initializes tooltips/popovers through Bootstrap 5's native constructors (the jQuery plugin interface disappears with jQuery) - Rewrites navbar cover-transparency and overflow-indicator logic with DOM APIs: readyState-guarded ready() helper (the chrome-nav.js idiom), getBoundingClientRect + scrollY for document-relative offsets, classList.toggle with force flag, scrollBy smooth scrolling in place of jQuery animate, passive scroll listeners - Keeps the pre-existing re-attach of indicator click handlers on resize as-is (faithful conversion; same stacking in the jQuery version) - Extends the js-runtime net with both base.js probes, green pre-conversion: cover transparency toggling off after scrolling past a tall home cover, and mobile-viewport overflow indicators + click-to-scroll
- Handles every .td-search input explicitly (jQuery collections did this implicitly): per-input change handlers and index-loaded re-render
- Replaces $.ajax with fetch, adding the response.ok guard and an error log ($.ajax failures were silent)
- Rebuilds the results popover with createElement + textContent throughout: query, titles, and excerpts are user- or index-controlled, so none of them ever meet innerHTML
- Maps the remaining idioms per prior art: addEventListener {once} for the one-shot shown.bs.popover hook, dataset reads with explicit parseInt (jQuery .data auto-coerced), bubbling synthetic change events, getBoundingClientRect for the viewport-relative popover height
- Adds a js-runtime probe, green pre-conversion: a committed query pops the results popover and its close button clears the input
- Removes the last jQuery artifact: the unconditional code.jquery.com script in head.html; every dependent script is already converted, so no page loads or needs jQuery (one fewer third-party request on every page, and one less non-local resource for GDPR-sensitive sites) - Adds tests/fixture-site/no-jquery.test.mjs as the regression lock: rendered fixture pages reference no jquery script, and authored theme JS carries no jQuery usage tokens (red-proven against the pre-drop tag, landed green) - Hardens the offline-search probe's close-button step against full-suite load flake (retry loop instead of a fixed settle delay)
- The harness aborts off-origin requests, so shots never loaded the jQuery CDN script: base.js threw and killed the rest of the concatenated bundle, and the goldens captured that JS-dead chrome (visibly: red placeholder glyphs, un-initialized dark-mode toggler) - With the bundle now self-sufficient offline, shots render what jQuery-loading production pages always did; breadcrumb crops are unaffected - Linux set needs the CI-artifact flow (update:visual-goldens:linux) once the branch has a failed visual run
- Same refresh as the darwin set, via the CI-artifact flow (update:visual-goldens:linux) from this branch's first visual run
…nore - offline-search.js: restores stopPropagation on the search form's submit (jQuery's `return false` stopped propagation too; site-level delegated listeners never saw the event) - Search probe: query now carries reserved characters, pinning the encodeURIComponent behavior (red-proven against an unencoded build) - Mermaid: adds a dark-theme render probe, covering the converted data-bs-theme sniff branch - lychee.toml: drops the code.jquery.com exclusion, obsolete with the CDN tag gone
- base.js: tooltip/popover init via getOrCreateInstance, matching Bootstrap's own jQuery interface (an element matching two init selectors gained a second instance and popped where the original stayed silent); overflow logic tolerates partial custom navbar markup like the original's empty-selection no-ops (only .navbar-nav is required) - markmap.js: replaces unique parents with their full text, like the jQuery original (sibling code blocks in a hand-authored shared parent lost surrounding text and deduplication)
- Console-error net: resource-load failures now count when a same-origin script or stylesheet fails (a broken first-party bundle previously passed as CDN noise); collector self-test covers the missing-script path - Absence gate: JS scan catches $., $ (, and jQuery aliasing; includes first-party static JS (tabpane-persist.js -- the vendored-directory claim was wrong); layouts also scanned for jquery script URLs; per-category file floors so one emptied glob can't hide behind another's count (evasion samples and Hugo $.-idiom non-matches verified) - Probes: each interaction probe carries a pageerror collector (mid-probe handler exceptions failed silently); mermaid dark probe asserts the rendering differs from light (SVG theme style), not just that an SVG appeared; plantuml probe asserts the image payload loads, pinning the deflate + encode64 pipeline end-to-end - offline-search probe: retry loop tolerates mid-transition close-button clicks
- globSync returns backslash paths on Windows, so the slash-anchored filter let prism.js into the scan (Windows CI red)
- Deliberate behavior fix, owner-approved: the jQuery-era code re-attached the handlers on every resize-triggered overflow re-check, stacking them so each indicator click scrolled N times after N re-checks
- Changelog: Breaking entry -- runtime behavior is in the documented public contract, and sites whose scripts used Docsy's window-global jQuery break - Release post: upgrade triage (no action for most sites; convert or self-load jQuery via hooks/head-end.html for the rest), landed now per the post scaffold's route-as-you-land note; release prep shapes the final post
- The blog section's new external URLs left CI's is:clean gate red (the link check writes them into docsy.dev/.lycheecache)
…dedup - search.js: an Enter that commits an IME composition no longer navigates (isComposing guard; the jQuery-era keypress never fired for it) - offline-search.js: an absent max-results attribute means unlimited again, as before the conversion (parseInt's NaN sliced to zero results on sites with a customized search-input partial) - plantuml.js: unique-parent iteration like markmap.js (sibling code blocks fired a stray diagram-server request for a never-inserted img) - Dark-mermaid probe: theme attribute lands as soon as the document element exists (DOMContentLoaded lost the race to a cache-hot async module) - Blog copy: "one less" -> "one fewer" - Changelog: user-visible fixes (indicator click stacking, query truncation) added under Other changes
…eness - offline-search.js: results base-href reads from the first search input, matching the jQuery collection read exactly (the per-target read was an undeclared delta for customized multi-input partials) - base.js: authored theme JS stays free of optional chaining -- plain guards match the rest of the converted files. (The reviewer's bundle-parse-floor concern turned out pre-existing: Hugo's minifier already emits two optional-chaining tokens into Popper's code on live docsy.dev, so the floor was ES2020 before this branch) - Changelog: the IME-composition fix joins the search-box Other-changes entry
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.
base,search,offline-search,markmap,plantuml, and the mermaid partial move to native DOM APIs (Bootstrap 5 constructors,fetch,classList, smoothscrollBy, delegatedkeydown); the unconditional code.jquery.com script leaveshead.html-- one fewer third-party request on every page, and one fewer non-local resource for privacy-sensitive sites&/#); offline-search index-fetch failures are logged and HTTP errors guarded (previously silent); Enter during IME composition no longer navigates; navbar scroll-indicator click handlers attach once (previously stacked on every resize, scrolling N times per click)tests/visual/js-runtime.test.mjs, riding the visual CI job) landed red-proven before the conversions; each conversion carries a behavior probe verified green against the pre-conversion jQuery code;tests/fixture-site/no-jquery.test.mjslocks the end state (rendered pages reference no jquery script, authored theme JS carries no jQuery usage), red-proven pre-dropbase.jstook down the whole concatenated bundle; both platform sets refreshed (darwin locally, Linux via the CI-artifact flow) now that the bundle runs offlinehooks/head-end.html)offline-search.jsis the deep one (fetch + XSS-safe DOM construction for the results popover)