From 2d184b705b9d767abe523f57c9a6a7c6d13affe4 Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Wed, 4 May 2022 18:08:15 -0400 Subject: [PATCH] squash bug with indices not updating appropriately --- script/helpers/get-liquid-conditionals.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/helpers/get-liquid-conditionals.js b/script/helpers/get-liquid-conditionals.js index 44ec9899a328..9143f920580c 100644 --- a/script/helpers/get-liquid-conditionals.js +++ b/script/helpers/get-liquid-conditionals.js @@ -72,7 +72,9 @@ function getLiquidConditionalsWithContent(str, tagName) { function groupTokens(tokens, tagName, endTagName, newArray = []) { const startIndex = tokens.findIndex((token) => token.conditional === tagName) // The end tag name is currently in a separate token, but we want to group it with the start tag and content. - const endIndex = tokens.findIndex((token) => token.conditional === endTagName) + const endIndex = tokens.findIndex( + (token, index) => token.conditional === endTagName && index > startIndex + ) // Once all tags are grouped and removed from `tokens`, this findIndex will not find anything, // so we can return the grouped result at this point. if (startIndex === -1) return newArray