Repository navigation
feat: run framework helpers through declared JavaScript - #26858
Conversation
Declared JavaScript runs against the element and has no way to reach the callbacks that an executeJs expression gets through its context object, such as stopApplication or the element to state node mapping. Framework code that needs them can therefore not move off string expressions. A @JsDefinition method annotated with the internal @JsWithExecutionContext is generated into a separate bundle registry as a function taking that context as its first parameter, executionContext, while `this` stays the element. The client passes the context only to functions found in that registry, and the marker is part of the function id. Part of #26698
Page.open/setLocation, attaching an existing element and the polymer template model sync no longer send string expressions. They are declared @JsExpression methods marked with @JsWithExecutionContext, so they reach the same helpers through executionContext and work under a content security policy without unsafe-eval. Part of #26698
|
Fixed the reported issues in |
vaadin-review-bot
left a comment
There was a problem hiding this comment.
✅ Nothing to flag — the changes look good.
|
|
Documentation Bot: No documentation needed for this change. The change moves three framework-internal call sites ( Nothing was opened in vaadin/docs. If you disagree, the change has to be documented by hand there.
|
|
This ticket/PR has been released with Vaadin 25.4.0-alpha6. |



Review risk: two-way door —
Page.open/setLocation, attaching existing elements and polymer template model sync move to declared JavaScript; if wrong, those features break in the browser, and reverting restores the string expressions.Part of #26698
Depends on #26857
Summary
The last framework call sites that sent string expressions because they need client-side helpers now use declared JavaScript with the execution context added in #26857. They therefore work under a content security policy without
unsafe-eval, and what runs in the browser is the same as before.What changed
Page.open(…),openUnsafe(…)andsetLocation(…)runPage.NavigationJs.open(url, windowName). It still dispatchesvaadin-redirect-pending, calls$executionContext.stopApplication()for_self, and then callswindow.open.NavigationJsis a new nested interface marked internal-only, kept apart from the publicPageJsbecause it does not check the URL itself.AbstractNodeStateProvider.attachExistingElementrunsAttachExistingElementJs.attachExistingElement(parent, previousSibling, tagName, id). The parent can be an element or a shadow root.AbstractTemplate(flow-polymer-template) runsTemplateModelJs.registerUpdatableModelProperties/populateModelProperties.this.replaced by$executionContext.. The deferral until nodes are bound and the call order are unchanged.asyncfunctions. An exception thrown inside one, with no result subscriber, now shows up as an unhandled promise rejection instead of being reported through the client console logger. Timing does not change: none of the bodies awaits.Test summary
setLocation,open,openUnsafe, attaching an existing element, and template model registration/population. They also check that an unsafe URL queues nothing.PageIT(test-default), andAttachExistingElementIT,AttachExistingElementByIdIT,UpdatableModelPropertiesITandPolymerModelPropertiesIT(test-root-context). The generated bundle contained the new functions in the context registry.API Changes
Fixes #26698