cards-testimonial.js security and complexity fixes, also fixed white stars#678
Open
helms-charity wants to merge 1 commit intomainfrom
Open
cards-testimonial.js security and complexity fixes, also fixed white stars#678helms-charity wants to merge 1 commit intomainfrom
helms-charity wants to merge 1 commit intomainfrom
Conversation
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
Commits
|
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.
Fix #677
Test URLs:
Testing: THere should be no changes from Main except the white stars now show for grey cards.
[1
Summary of changes that keep decorate at no more than 4 levels of nesting:
New helpers (each with its own, limited nesting):
buildCardsFromRows(rows) – Builds the cards container from block rows (row loop + child loop and class assignment). Replaces the previous double forEach inside decorate.
optimizePicturesInContainer(cardsContainer) – Handles the picture > img optimization and dataset copy. Replaces the inner picture forEach in decorate.
copyBlockPropertiesFromContext(block) – Copies swipable, autoplayEnabled, and startingCard from section/block-content to the block. Replaces the [blockContent, section].forEach(...) block in decorate.
setImageDimensionsFromRects(block) – Sets dataset width/height from getBoundingClientRect() for images that don’t have them. Used inside requestAnimationFrame so the frame callback stays at one level: requestAnimationFrame(() => setImageDimensionsFromRects(block)) (3 levels total).
waitForSwiperLib() – Returns the Promise that waits for Swiper (with setInterval/setTimeout). The Swiper-wait logic is no longer nested inside decorate.
updateStarIconInSlide(slide, activeSlide) – Updates star icons for a single slide. The previous updateStarIcons had requestAnimationFrame → slides.forEach → inner forEach (6 levels). Now updateStarIcons only does requestAnimationFrame → slides.forEach((slide) => updateStarIconInSlide(slide, activeSlide)) (4 levels), and the per-slide work lives in updateStarIconInSlide (max 3 levels).
decorate now:
Calls these helpers instead of inlining their logic.
Keeps nesting at at most 4 levels (e.g. decorate → if (!isSwipable) → requestAnimationFrame → callback; or decorate → updateStarIcons → requestAnimationFrame → slides.forEach).