fix(platform-browser): collect external component styles from server … · angular/angular@ae0802d · GitHub
Skip to content

Commit ae0802d

Browse files
clydinalxhub
authored andcommitted
fix(platform-browser): collect external component styles from server rendering (#59031)
SSR generated component styles used in development environments will add external styles via link elements to the HTML. However, the runtime would previously not collect these link elements for reuse with rendered components. This would result in two copies of the link elements present in the DOM. In isolation this is not problematic as it is only present in development mode. Unfortunately, the Vite-based CSS HMR functionality used by the Angular CLI only updates the first stylesheet it finds and leaves other instances of the stylesheet in place. This behavior causes the styles to be left in an inconsistent state. This could be considered a defect within Vite as it should update all relevant styles to maintain consistency but ideally there should not be two instances in the Angular SSR case. To avoid the Vite issue, the runtime will now collect SSR generated external styles and reuse them. PR Close #59031
1 parent c521ce1 commit ae0802d

2 files changed

Lines changed: 46 additions & 10 deletions

File tree

‎packages/platform-browser/src/dom/shared_styles_host.ts‎

Lines changed: 19 additions & 10 deletions

‎packages/platform-browser/test/dom/shared_styles_host_spec.ts‎

Lines changed: 27 additions & 0 deletions

0 commit comments

Comments
 (0)