Skip to content

Commit

Permalink
fix(core): add additional component metadata to component ID generati…
Browse files Browse the repository at this point in the history
…on (angular#50203)

This commit add `exportAs`, `signals`, `inputs` and `outputs` into account when generating a component ID.

See: angular#50158 (comment)

PR Close angular#50203
  • Loading branch information
alan-agius4 authored and alxhub committed May 9, 2023
1 parent f751ce6 commit 52c74d3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/render3/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ function getComponentId(componentDef: ComponentDef<unknown>): string {
// https://github.com/angular/components/blob/d9f82c8f95309e77a6d82fd574c65871e91354c2/src/material/core/option/option.ts#L248
// https://github.com/angular/components/blob/285f46dc2b4c5b127d356cb7c4714b221f03ce50/src/material/legacy-core/option/option.ts#L32

const hashSelectors = [
const hashSelectors = JSON.stringify([
componentDef.selectors,
componentDef.ngContentSelectors,
componentDef.hostVars,
Expand All @@ -689,12 +689,16 @@ function getComponentId(componentDef: ComponentDef<unknown>): string {
componentDef.decls,
componentDef.encapsulation,
componentDef.standalone,
componentDef.signals,
componentDef.exportAs,
componentDef.inputs,
componentDef.outputs,
// We cannot use 'componentDef.type.name' as the name of the symbol will change and will not
// match in the server and browser bundles.
Object.getOwnPropertyNames(componentDef.type.prototype),
!!componentDef.contentQueries,
!!componentDef.viewQuery,
].join('|');
]);

for (const char of hashSelectors) {
hash = Math.imul(31, hash) + char.charCodeAt(0) << 0;
Expand Down

0 comments on commit 52c74d3

Please sign in to comment.