Skip to content

Commit de5aa35

Browse files
committed
Add circular effect scheduler regression test
1 parent 65b1300 commit de5aa35

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { html, test } from '../../utils'
2+
3+
test('effects that trigger each other do not requeue endlessly in the same flush',
4+
[html`
5+
<div x-data="{ a: 0, b: 0 }">
6+
<button @click="window.__allowCircularEffects = true; a++">start</button>
7+
8+
<span x-effect="a; if (window.__allowCircularEffects) { if (++window.__circularEffectRuns > 4) throw new Error('Circular effects requeued endlessly'); b++ }"></span>
9+
<span x-effect="b; if (window.__allowCircularEffects) { if (++window.__circularEffectRuns > 4) throw new Error('Circular effects requeued endlessly'); a++ }"></span>
10+
</div>
11+
`,
12+
`
13+
window.__allowCircularEffects = false
14+
window.__circularEffectRuns = 0
15+
`],
16+
({ get }) => {
17+
get('button').click()
18+
}
19+
)

0 commit comments

Comments
 (0)