Skip to content

fix(view): invoke bq-on handlers via evaluation, not a paren heuristic - #200

Merged
JosunLP merged 1 commit into
devfrom
fix/180-bq-on-invoke
Jul 6, 2026
Merged

fix(view): invoke bq-on handlers via evaluation, not a paren heuristic#200
JosunLP merged 1 commit into
devfrom
fix/180-bq-on-invoke

Conversation

@JosunLP

@JosunLP JosunLP commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #180 (Low; correctness — silent no-op).

bq-on decided "bare function reference vs. call" by testing whether the expression string contained (. This misfires on expressions where the paren is not the top-level call:

<button bq-on:click="items.find(x => x).handler">

was treated as a full expression, evaluated once, and the returned handler was never invoked — the click silently did nothing.

Fix

Both bq-on sinks (on.ts and on-modifiers.ts) now share runOnExpression: always evaluate the expression via evaluateRaw, and if the result is a function, invoke it with the event; otherwise the evaluation itself was the side effect (count.value++, handleClick($event)). The string heuristic is removed. (this remains unbound for a function resolved from a member chain — use an explicit call when the receiver matters, as before.)

Verification

  • New tests: a handler resolved from items.find(matcher).handler now fires; a bare onClick reference is invoked with the event. The inner-paren case is exactly what silently no-op'd on the pre-fix code.
  • Existing bq-on tests (bare ref, handleClick($event), count.value++/--/+=) still pass.
  • view suites: 119 pass / 0 fail. tsc --noEmit + eslint clean.

🤖 Generated with Claude Code

bq-on decided 'bare reference vs. call' by testing whether the expression
string contained '('. This misfired on expressions with a non-top-level
paren, e.g. items.find(x=>x).handler: treated as a full expression,
evaluated once, and the returned handler was never invoked — the click
silently did nothing.

Both bq-on sinks now share runOnExpression: always evaluate via
evaluateRaw and, if the result is a function, invoke it with the event;
otherwise the evaluation itself was the side effect (count.value++,
handleClick($event)). The fragile string heuristic is gone.

Fixes #180

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions github-actions Bot added view Changes to the view module tests Chenges to the tests labels Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 92b31089-93a0-4b62-b76d-6aa7ce487c67

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/180-bq-on-invoke

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JosunLP
JosunLP merged commit d6cafe9 into dev Jul 6, 2026
9 checks passed
@JosunLP
JosunLP deleted the fix/180-bq-on-invoke branch July 6, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Chenges to the tests view Changes to the view module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant