| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
During hot module replacement (HMR), updating component inline styles (`<style>`) or external stylesheet URLs (`<link rel="stylesheet">`) previously triggered a complete destruction and recreation of matching component view trees (`LView`). This caused loss of live application state (such as input values, scroll positions, component signal state, and iframe instances) whenever a CSS or SCSS file was edited. This change introduces `replaceStyles` on `SharedStylesHost`, allowing HMR to mutate inline style `textContent` or link `href` attributes in-place. The method accepts an `isScoped` flag (`oldDef.encapsulation !== ViewEncapsulation.None`) to distinguish component-scoped styles from un-encapsulated styles: - For scoped styles (`isScoped === true`), in-place mutation and tracking record re-keying runs regardless of `record.usage`, preserving active instance usage counts so that multi-instance components unmount cleanly without premature style removal. - For unscoped styles (`isScoped === false`), if `record.usage > 1`, it falls back to `removeUsage` + `addUsage` to protect other component classes sharing identical un-encapsulated initial CSS. If non-style metadata (such as `template`, `inputs`, `outputs`, `providers`, `hostBindings`, `selectors`, or `hostDirectives`) or encapsulation (`ShadowDom`) changes alongside styles, HMR safely falls back to view tree recreation.
|
This draft PR is being closed because it has been stale for 28 days and has seen no activity from you. If you'd like to see this change land, you can re-open this PR. Thank you for being an Angular contributor! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
During hot module replacement (HMR), updating component inline styles
(<style>) or external stylesheet URLs (<link rel="stylesheet">) previously
triggered a complete destruction and recreation of matching component view
trees (LView). This caused loss of live application state (such as input
values, scroll positions, component signal state, and iframe instances) whenever
a CSS or SCSS file was edited.
This change introduces replaceStyles on SharedStylesHost, allowing HMR to
mutate inline style textContent or link href attributes in-place. The method
accepts an isScoped flag (oldDef.encapsulation !== ViewEncapsulation.None)
to distinguish component-scoped styles from un-encapsulated styles:
record re-keying runs regardless of record.usage, preserving active instance
usage counts so that multi-instance components unmount cleanly without premature
style removal.
back to removeUsage + addUsage to protect other component classes sharing
identical un-encapsulated initial CSS.
If non-style metadata (such as template, inputs, outputs, providers,
hostBindings, selectors, or hostDirectives) or encapsulation (ShadowDom)
changes alongside styles, HMR safely falls back to view tree recreation.