import { DaffStyleInjector } from '@daffodil/content'
Service for injecting style tags into the document head. Useful for dynamically generated styles that need to be cleaned up later. Memoizes styles to avoid duplicate style tags for the same CSS.
@Injectable()
class DaffStyleInjector {
inject(css: string): HTMLStyleElement
destroy(styleTag: HTMLStyleElement): void
destroyAll(): void
}
HTMLStyleElementInjects a style tag into the document head with the provided CSS. Returns the cached style element if the same CSS was already injected.
| Parameter | css: string |
|---|---|
| Description | The CSS string to inject |
voidRemoves a specific style tag from the document and cache.
| Parameter | styleTag: HTMLStyleElement |
|---|---|
| Description | The style element to remove |
voidRemoves all injected style tags from the document and clears the cache.