diff --git a/lib/hacks/grid-utils.js b/lib/hacks/grid-utils.js index a552ec3d6..7f6403ad6 100644 --- a/lib/hacks/grid-utils.js +++ b/lib/hacks/grid-utils.js @@ -511,7 +511,15 @@ function insertAreas (css, isDisabled) { // if we can't find the area name, update lastRule and continue if (!area) { - let lastRuleIndex = css.index(rulesToInsert[lastArea].lastRule) + let lastRule = rulesToInsert[lastArea].lastRule + let lastRuleIndex + if (lastRule) { + lastRuleIndex = css.index(lastRule) + } else { + /* istanbul ignore next */ + lastRuleIndex = -1 + } + if (gridAreaRuleIndex > lastRuleIndex) { rulesToInsert[lastArea].lastRule = gridAreaMedia || gridAreaRule }