Skip to content

refactor: Actions and Inputs render as JsFunctions#24433

Open
Artur- wants to merge 6 commits into
mainfrom
action-input-jsfunc
Open

refactor: Actions and Inputs render as JsFunctions#24433
Artur- wants to merge 6 commits into
mainfrom
action-input-jsfunc

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented May 24, 2026

Replace appendStatement(JsBuilder, StringBuilder) on Action with render(JsBuilder): JsFunction. Replace Input.appendExpression with Input.toJs(JsBuilder): JsFunction returning the input's value when
invoked.

Each Action ships as its own JsFunction (body + captures); Trigger composes them as captures of a tiny parent JsFunction whose body is just $0(event);$1(event);... PromiseAction wraps the subclass JsFunction with OBSERVE_PROMISE via captures instead of string concatenation.

Eliminates hand-escaped JS literals in action bodies — strings and Element refs go through JsFunction's capture mechanism, which Jackson-encodes on the wire. Removes the "this" special-case for the host element: the host is captured the same way as any other Element.

JsBuilder shrinks to just the render-time context (trigger() accessor) plus a static json() helper kept for Trigger.installJs() (a raw String, not a JsFunction).

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 24, 2026

Test Results

 1 421 files  ±0   1 421 suites  ±0   1h 23m 0s ⏱️ + 3m 14s
10 011 tests +1   9 943 ✅ +1  68 💤 ±0  0 ❌ ±0 
10 483 runs  +1  10 414 ✅ +1  69 💤 ±0  0 ❌ ±0 

Results for commit 1204bea. ± Comparison against base commit d9afcc4.

♻️ This comment has been updated with latest results.

Replace appendStatement(JsBuilder, StringBuilder) on Action with
render(JsBuilder): JsFunction. Replace Input.appendExpression with
Input.toJs(JsBuilder): JsFunction returning the input's value when
invoked.

Each Action ships as its own JsFunction (body + captures); Trigger
composes them as captures of a tiny parent JsFunction whose body is
just $0(event);$1(event);... PromiseAction wraps the subclass JsFunction
with OBSERVE_PROMISE via captures instead of string concatenation.

Eliminates hand-escaped JS literals in action bodies — strings and
Element refs go through JsFunction's capture mechanism, which Jackson-
encodes on the wire. Removes the "this" special-case for the host
element: the host is captured the same way as any other Element.

JsBuilder shrinks to just the render-time context (trigger() accessor)
plus a static json() helper kept for Trigger.installJs() (a raw String,
not a JsFunction).
@Artur- Artur- force-pushed the action-input-jsfunc branch from 5bb8b54 to f5b194e Compare May 25, 2026 10:05
@Artur- Artur- marked this pull request as ready for review May 25, 2026 10:05
@Artur- Artur- requested a review from mshabarov May 25, 2026 10:15
Artur- added 5 commits May 25, 2026 14:27
# Conflicts:
#	flow-server/src/main/java/com/vaadin/flow/component/trigger/internal/CopyTextToClipboardAction.java
#	flow-server/src/test/java/com/vaadin/flow/component/trigger/internal/WriteToClipboardActionTest.java
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant