_on(n4, "click", (...args) => (_ctx.handleClick && _ctx.handleClick(...args)))
_effect(() => {
_setText(n1, undefined, _ctx.count)
- })
- _effect(() => {
_setText(n2, undefined, _ctx.count)
- })
- _effect(() => {
_setText(n3, undefined, _ctx.count)
- })
- _effect(() => {
_setAttr(n4, "id", undefined, _ctx.count)
})
return n0
) {
return this.registerOperation(...operations)
}
- // TODO combine effects
- effect.push({
- expressions: expressions as IRExpression[],
- operations,
- })
+ const existing = effect.find((e) =>
+ isSameExpression(e.expressions, expressions as IRExpression[]),
+ )
+ if (existing) {
+ existing.operations.push(...operations)
+ } else {
+ effect.push({
+ expressions: expressions as IRExpression[],
+ operations,
+ })
+ }
+
+ function isSameExpression(a: IRExpression[], b: IRExpression[]) {
+ if (a.length !== b.length) return false
+ return a.every(
+ (exp, i) => identifyExpression(exp) === identifyExpression(b[i]),
+ )
+ }
+
+ function identifyExpression(exp: IRExpression) {
+ return typeof exp === 'string' ? exp : exp.content
+ }
},
template: '',