Repository navigation
Carousel: expose window.frontblocksCarousel.init() to start lists added after load - #367
Open
Castellon-ACM wants to merge 1 commit into
Open
Castellon-ACM wants to merge 1 commit into
Castellon-ACM wants to merge 1 commit into
Conversation
…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.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
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.
Problem
frontblocks-carousel.jsonly starts the carousels in the windowloadevent 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 fakewindowto start them.Change
window.frontblocksCarousel.init( container )starts the.frontblocks-carousellists insidecontainer(default: the whole document). Lists that are already running are skipped, so it is safe to call more than once.loadthe script callsinit()as before, so existing pages behave the same.loadthat never comes.arrowsHTMLandactualViewwere implicit globals; they are now declared.Verification
tests/js/carousel-init-api.test.js(5 tests), added topackage.jsonand the CI workflow. The existingcarousel-accessibilitytest still passes.init()do not nest or re-wrap, and the first carousel is untouched. No page errors.Not checked
init()once this is released (a follow-up in frontblocks-pro Add FAQ Schema (JSON-LD) support for native Gutenberg FAQ block and GenerateBlocks Accordion #130).readme.txthas no "Unreleased" section.