Skip to content

fix(web_core,angular): guard partial test mocks and 3-arg ComponentModel catalog fallback - #3829

Open
gspencergoog wants to merge 4 commits into
a2ui-project:mainfrom
gspencergoog:fix/angular-component-host-optional-guards
Open

gspencergoog wants to merge 4 commits into
a2ui-project:mainfrom
gspencergoog:fix/angular-component-host-optional-guards

Conversation

@gspencergoog

Copy link
Copy Markdown
Collaborator

Summary

Restore catalog fallback in NodeResolver, DataContext, GenericBinder, and ComponentHostComponent for the 3-argument ComponentModel constructor. Guard optional properties on partial unit test stand-ins.

Reviewer Focus

  • Check NodeResolver.catalogFor in typescript/core/web_core/src/resolution/node-resolver.ts so model.catalog still takes precedence when bound and falls back to surface.defaultCatalog ?? surface.catalog only when model.catalog is undefined.
  • Check ComponentHostComponent in typescript/renderers/angular/src/core/component-host.component.ts so onUpdated and onMetadataChanged subscriptions behave the same on full ComponentModel instances while tolerating partial unit test stand-ins.

Changes

  • Fall back to surface.defaultCatalog ?? surface.catalog in resolveSurfaceCatalog, DataContext, and NodeResolver.catalogFor when model.catalog or surface.defaultCatalog is omitted.
  • Guard extractRefFields(undefined) in ref-fields.ts and getFieldBehavior(undefined) plus componentModel.onUpdated?.subscribe(...) in generic-binder.ts.
  • Guard surface.componentsModel?.get(...), surface.dispatchError?.(...), compCatalog?.components?.get(...), and model.metadataSignal in NodeResolver.
  • Guard onUpdated?.subscribe(...) and onMetadataChanged?.subscribe(...), and include surface.catalog in reportUnresolved in ComponentHostComponent.
  • Add unit tests in node-resolver.test.ts and component-host.component.spec.ts covering the 3-argument ComponentModel constructor (#3658) and partial stand-ins.

Impact & Risks

No breaking changes or wire-protocol changes. Multi-catalog v1.0 surfaces still resolve each ComponentModel strictly against its bound model.catalog without falling back across catalogs.

Testing

  • Built, linted, and ran unit and conformance suites in @a2ui/web_core.
  • Built, linted, and ran unit and integration suites in @a2ui/angular.

…del catalog fallback

PR a2ui-project#3658 restored the 3-argument `new ComponentModel(id, type, properties)` constructor where `model.catalog` is `undefined`. PR a2ui-project#3706 and PR a2ui-project#3757 moved `ComponentHostComponent` onto `NodeResolver` and reactive `metadataSignal` and `onMetadataChanged` bindings. Callers using the 3-argument constructor or partial `SurfaceModel` and `ComponentModel` stand-ins hit `TypeError` dereferences on missing catalog, metadata, or emitter properties.

Fall back to `surface.defaultCatalog ?? surface.catalog` only when `model.catalog` is `undefined` to preserve v1.0 per-component catalog isolation. Guard optional subscriptions and metadata signals across `NodeResolver`, `DataContext`, `GenericBinder`, and `ComponentHostComponent`.
@gspencergoog
gspencergoog force-pushed the fix/angular-component-host-optional-guards branch from 8d1afdb to dba1e93 Compare November 2, 2026 16:52
gemini-code-assist[bot]

This comment was marked as resolved.

…nt-host-optional-guards

# Conflicts:
#	typescript/core/web_core/CHANGELOG.md
#	typescript/core/web_core/src/resolution/data-context.ts
#	typescript/core/web_core/src/resolution/generic-binder.ts
#	typescript/core/web_core/src/resolution/ref-fields.ts
#	typescript/renderers/angular/CHANGELOG.md
#	typescript/renderers/angular/src/core/component-host.component.ts
`SurfaceModel` already types its `catalog` getter, and `Catalog` already types `id`. Read `surface.catalog` directly in `NodeResolver` and drop the `as AngularCatalog | undefined` cast in `ComponentHostComponent.reportUnresolved`.

This branch has not been deployed

No deployments
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.

1 participant