Skip to content

Commit

Permalink
squash bug with indices not updating appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorsector committed May 13, 2022
1 parent 80ff57f commit 2d184b7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion script/helpers/get-liquid-conditionals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d184b7

Please sign in to comment.