Skip to content

fix(fast-html): only process single-brace bindings for event aspect#7325

Draft
janechu wants to merge 4 commits intomainfrom
users/janechu/fix-curly-braces-only-event-aspect
Draft

fix(fast-html): only process single-brace bindings for event aspect#7325
janechu wants to merge 4 commits intomainfrom
users/janechu/fix-curly-braces-only-event-aspect

Conversation

@janechu
Copy link
Collaborator

@janechu janechu commented Mar 17, 2026

Summary

Restricts single curly brace ({}) client-side bindings in fast-html to only be processed when the DOMAspect is an event (@) or an attribute directive (f-). This prevents CSS/JS curly braces from being misinterpreted as bindings.

Changes

  • utilities.ts: Modified getNextBehavior() to loop and skip single-brace bindings that are not events or attribute directives. When a non-event {} is encountered, parsing advances past the closing } and continues searching for valid bindings.
  • utilities.spec.ts: Added 4 new tests:
    • CSS braces in <style> are correctly skipped
    • Single-brace non-event attribute bindings are skipped
    • Double-brace binding found after skipped CSS braces
    • Event binding found after skipped CSS braces

What still works

  • @click="{handler()}" — event bindings ✅
  • f-children="{list}" — attribute directives ✅
  • {{text}} — double-brace server-side bindings ✅
  • {{{html}}} — triple-brace unescaped bindings ✅

What's now skipped

  • <style>.foo { color: red }</style> — CSS braces ✅
  • <input type="{type}"> — non-event single-brace attributes ✅

Resolves #7295

Single curly brace ({}) bindings in fast-html are now restricted to
event (@) and attribute directive (f-) bindings only. This prevents
CSS/JS curly braces from being misinterpreted as client-side bindings.

- Modified getNextBehavior() to skip non-event single-brace bindings
- Double-brace ({{ }}) and triple-brace ({{{ }}}) bindings are unaffected
- Added tests for CSS braces, non-event attributes, and mixed scenarios

Resolves #7295

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu marked this pull request as draft March 17, 2026 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change client side bindings from single curly brace to another syntax

1 participant