Skip to content

Carousel: expose window.frontblocksCarousel.init() to start lists added after load - #367

Open
Castellon-ACM wants to merge 1 commit into
trunkfrom
feature/carousel-init-api
Open

Castellon-ACM wants to merge 1 commit into
trunkfrom
feature/carousel-init-api

Conversation

@Castellon-ACM

@Castellon-ACM Castellon-ACM commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

frontblocks-carousel.js only starts the carousels in the window load event and exposes nothing. Code that adds lists later (AJAX, REST, the PRO recently viewed carousel) has to download and re-run the whole script with a fake window to start them.

Change

  • window.frontblocksCarousel.init( container ) starts the .frontblocks-carousel lists inside container (default: the whole document). Lists that are already running are skipped, so it is safe to call more than once.
  • On load the script calls init() as before, so existing pages behave the same.
  • If the script runs after the window has already loaded, it starts at once instead of waiting for a load that never comes.
  • arrowsHTML and actualView were implicit globals; they are now declared.

Verification

  • New tests/js/carousel-init-api.test.js (5 tests), added to package.json and the CI workflow. The existing carousel-accessibility test still passes.
  • Headless Chromium with the real Glide: a list inserted after load starts once with 3 bullets, three calls to init() do not nest or re-wrap, and the first carousel is untouched. No page errors.

Not checked

Open WordPress Playground Preview

…ed after load

The script only started carousels in the window "load" event and had no way to
start lists added later (AJAX, REST), so add-ons had to re-run the whole file.

- init( container ) starts the lists inside the container (default: document)
  and skips the ones already running, so calling it twice is safe.
- If the script runs after the window has loaded, it starts at once instead of
  waiting for a "load" that never comes.
- Declare two variables that were implicit globals (arrowsHTML, actualView).
- Add JS tests, registered in package.json and the CI workflow.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-25T11:43:30.747977Z
We couldn’t complete this review. Comment @codex review to try again.
bf8e0a2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant