Repository navigation
feat(web_core): universal elements accept an optional node - #2880
Merged
Merged
Conversation
josemontespg
force-pushed
the
web-core-elements-accept-node
branch
from
September 29, 2026 19:08
270587f to
a6ef6d0
Compare
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for passing an optional node (ComponentNode) to universal elements (A2uiWebComponentElement and A2uiLitElement). When provided, A2uiLitElement derives its context from the node and resolves its children through it. Additionally, renderA2uiNode has been overloaded to accept a ComponentNode directly. Relevant unit tests and changelog entries have been added to verify these changes. I have no further feedback to provide.
josemontespg
force-pushed
the
web-core-elements-accept-node
branch
2 times, most recently
from
September 29, 2026 22:47
e0ff92a to
dec5c92
Compare
josemontespg
marked this pull request as ready for review
September 29, 2026 23:15
josemontespg
force-pushed
the
web-core-elements-accept-node
branch
from
September 30, 2026 00:19
dec5c92 to
c12ed82
Compare
josemontespg
force-pushed
the
web-core-elements-accept-node
branch
from
September 30, 2026 18:38
c12ed82 to
3447116
Compare
A2uiWebComponentElement gains node, next to context. A renderer that resolves its surface through a NodeResolver sets both (context = node.context); an element that supports node uses it, the others keep reading context. A2uiLitElement takes its context from the node and renders its children from the node's own children, and renderA2uiNode accepts a ComponentNode. This lets Lit and Angular move to nodes one parent at a time.
josemontespg
force-pushed
the
web-core-elements-accept-node
branch
from
September 30, 2026 19:06
3447116 to
e723794
Compare
josemontespg
added a commit
that referenced
this pull request
Oct 5, 2026
### Summary The v0_9 React renderer now supports universal components. `A2uiSurface` wraps every React implementation of the surface's catalogs into a `WebComponentImplementation` and then renders everything as web components, using `node` (#2880), the way web_core's `renderA2uiNode` and Lit parents do. A catalog can now mix React implementations and web components from `@a2ui/web_core`. A React host element holds no implementation. When React creates one, React renders the node's `view` as the host's children. When a Lit parent creates one, the host registers with its surface's `HostRegistry` under the nearest React-rendered element above it, and the React content beside that element portals the `view` into it, keyed by `node.id` (#2887). Everything stays in the one React root, and the React tree nests like the DOM: providers, error boundaries and event handlers of a parent component apply to the components it renders, through any Lit component in between. The one new public type is `ReactCatalogComponent` (a React implementation or a `WebComponentImplementation`), exported from `@a2ui/react/v0_9`; `A2uiSurface` takes a `SurfaceModel<ReactCatalogComponent>`. `ReactComponentImplementation` and the two factories do not change. ### Breaking changes * Every React implementation renders inside a host custom element, `<a2ui-react-<name>>` with `display: contents`, one more element per component in the DOM. ### Changes * `catalog/prepare_catalogs.ts`, `catalog/to_web_component.tsx`: wrap the React entries of the surface's catalogs, once per catalog; repeated names get `-2`, `-3`, ... suffixes; web component entries are kept as they are. * `catalog/react_host_element.ts`, `host_registry.ts`: the host element, and the per-surface registry of the hosts Lit parents created, grouped by the React-rendered element above them. * `web_component_node.tsx`: renders a node as its element, marks it React-rendered and hands it `context` and `node`. * `node-view.tsx`: `NodeView` splits into `ChildElement` (a node's element, with `NodeContent` as children for a React node, or `HostedChildren` beside it for a Lit node), `NodeContent` (a node's `view`) and `HostedChildren` (one portal per registered host under an element). `useNodeView` takes the surface from the node's context and throws for a node without one, so `adapter.tsx` drops its loading branches. * `A2uiSurface.tsx`: prepares the catalogs and renders the root element. * `react_component_implementation.ts`, `index.ts`: the `ReactCatalogComponent` union and its export. The second commit, "react: nest the React tree like the DOM", is the change from sibling portals to this nesting, in response to review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Universal elements only received a
ComponentContext, so a parent that renders from resolvedComponentNodes had to hand each child a context and the child had to find its node again. Elements now also accept the node.contextremains supported, so Lit and Angular parents can move to nodes one at a time.Changes
A2uiWebComponentElement.node: optional. A node-based parent setsnodeandcontext = node.context, so elements that only readcontextkeep working. When both are set,nodewins.A2uiLitElement: anodeproperty; when assigned,contextis derived from it.renderNodepasses each child its ownComponentNodewhen the element has a node, and falls back to the context path otherwise.renderA2uiNodeaccepts aComponentNode(the implementation comes fromnode.impl), registers the element and renders<tag .node .context>.a2ui-lit-element.test.tsandrender-a2ui-node.test.ts.No change to
A2uiController, the basic components, the Lit surface or Angular.Verification
yarn --cwd typescript/web_core testyarn --cwd renderers/lit test:unit./scripts/fix_format.sh --check