Skip to content

Commit 22eaad1

Browse files
Fix "Maximum call stack size exceeded" bug (#8636)
* Fix potential call stack size issue * Update defaultExtractor.js * add test to verify "Maximum call stack size exceeded" is fixed * update changelog Co-authored-by: Robin Malfait <[email protected]>
1 parent 47327f4 commit 22eaad1

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Ignore PostCSS nodes returned by `addVariant` ([#8608](https://github.com/tailwindlabs/tailwindcss/pull/8608))
1515
- Fix missing spaces around arithmetic operators ([#8615](https://github.com/tailwindlabs/tailwindcss/pull/8615))
1616
- Detect alpha value in CSS `theme()` function when using quotes ([#8625](https://github.com/tailwindlabs/tailwindcss/pull/8625))
17+
- Fix "Maximum call stack size exceeded" bug ([#8636](https://github.com/tailwindlabs/tailwindcss/pull/8636))
1718

1819
## [3.1.2] - 2022-06-10
1920

src/lib/defaultExtractor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function defaultExtractor(context) {
1212
let results = []
1313

1414
for (let pattern of patterns) {
15-
results.push(...(content.match(pattern) ?? []))
15+
results = [...results, ...(content.match(pattern) ?? [])]
1616
}
1717

1818
return results.filter((v) => v !== undefined).map(clipAtBalancedParens)

tests/default-extractor.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -476,3 +476,9 @@ test('multi-word + arbitrary values + quotes', async () => {
476476

477477
expect(extractions).toContain(`grid-cols-['repeat(2)']`)
478478
})
479+
480+
test('a lot of data', () => {
481+
let extractions = defaultExtractor('underline '.repeat(2 ** 17))
482+
483+
expect(extractions).toContain(`underline`)
484+
})

0 commit comments

Comments
 (0)