@@ -6,18 +6,20 @@ import {
66 makeEnvironmentProviders ,
77} from '@angular/core' ;
88import { createCustomElement } from '@angular/elements' ;
9- import { provideMulti } from '@angularity/core' ;
9+ import { provideMulti , useBrowserOnly } from '@angularity/core' ;
1010
1111import { ELEMENT_REGISTRY , Elements } from './core' ;
1212
1313/**
14- * Offers a declarative approach to register Angular Elements.
14+ * Offers a declarative approach to register Angular Elements in the browser platform .
1515 *
1616 * @remarks The returned providers are for `EnvironmentInjector` only, e.g. `app.config.ts`,
1717 * route declarations, and NgModules. The registered Angular Elements will not be unregistered
1818 * when the `EnvironmentInjector` is destroyed, so make sure the `EnvironmentInjector` will not
1919 * be destroyed anytime in the application's lifecycle.
2020 *
21+ * @remarks If the current platform is not browser, this is a noop.
22+ *
2123 * @example
2224 * ```ts
2325 * export const APP_ELEMENTS: Elements = {
@@ -41,10 +43,12 @@ export function provideElements(
4143 useFactory :
4244 ( registry = inject ( ELEMENT_REGISTRY ) , injector = inject ( Injector ) ) =>
4345 ( ) => {
44- for ( const [ name , type ] of Object . entries ( config . elements ) ) {
45- const element = createCustomElement ( type , { injector } ) ;
46- registry . define ( name , element ) ;
47- }
46+ useBrowserOnly ( ( ) => {
47+ for ( const [ name , type ] of Object . entries ( config . elements ) ) {
48+ const element = createCustomElement ( type , { injector } ) ;
49+ registry . define ( name , element ) ;
50+ }
51+ } ) ;
4852 } ,
4953 } ) ,
5054 ] ) ;
0 commit comments