Skip to content

Commit 0b8d24e

Browse files
committed
feat(platform-browser): Updates
Updates after suggestion from team
1 parent 8813776 commit 0b8d24e

8 files changed

Lines changed: 9 additions & 19 deletions

File tree

packages/core/test/bundling/animations-standalone/bundle.golden_symbols.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@
200200
"PLATFORM_DESTROY_LISTENERS",
201201
"PLATFORM_ID",
202202
"PLATFORM_INITIALIZER",
203-
"PLATFORM_SERVER_ID",
204203
"PREORDER_HOOK_FLAGS",
205204
"PRESERVE_HOST_CONTENT",
206205
"PRESERVE_HOST_CONTENT_DEFAULT",
@@ -648,7 +647,6 @@
648647
"isNonAnimatableStyle",
649648
"isNotFound",
650649
"isObserver",
651-
"isPlatformServer",
652650
"isPositive",
653651
"isPromise",
654652
"isRefreshingViews",

packages/core/test/bundling/defer/bundle.golden_symbols.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"NAMESPACE_URIS",
3131
"NoneEncapsulationDomRenderer",
3232
"PLATFORM_BROWSER_ID",
33-
"PLATFORM_SERVER_ID",
3433
"REMOVE_STYLES_ON_COMPONENT_DESTROY",
3534
"REMOVE_STYLES_ON_COMPONENT_DESTROY_DEFAULT",
3635
"ShadowDomRenderer",
@@ -49,7 +48,6 @@
4948
"getBaseElementHref",
5049
"getDOM",
5150
"initDomAdapter",
52-
"isPlatformServer",
5351
"isTemplateNode",
5452
"parseCookieValue",
5553
"relativePath",

packages/core/test/bundling/forms_reactive/bundle.golden_symbols.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@
205205
"PLATFORM_DESTROY_LISTENERS",
206206
"PLATFORM_ID",
207207
"PLATFORM_INITIALIZER",
208-
"PLATFORM_SERVER_ID",
209208
"PREORDER_HOOK_FLAGS",
210209
"PRESERVE_HOST_CONTENT",
211210
"PRESERVE_HOST_CONTENT_DEFAULT",
@@ -745,7 +744,6 @@
745744
"isObserver",
746745
"isOptionsObj",
747746
"isPOJO",
748-
"isPlatformServer",
749747
"isPositive",
750748
"isPresent",
751749
"isPromise",

packages/core/test/bundling/forms_template_driven/bundle.golden_symbols.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@
202202
"PLATFORM_DESTROY_LISTENERS",
203203
"PLATFORM_ID",
204204
"PLATFORM_INITIALIZER",
205-
"PLATFORM_SERVER_ID",
206205
"PREORDER_HOOK_FLAGS",
207206
"PRESERVE_HOST_CONTENT",
208207
"PRESERVE_HOST_CONTENT_DEFAULT",
@@ -745,7 +744,6 @@
745744
"isObserver",
746745
"isOptionsObj",
747746
"isPOJO",
748-
"isPlatformServer",
749747
"isPositive",
750748
"isPresent",
751749
"isPromise",

packages/core/test/bundling/hydration/bundle.golden_symbols.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@
176176
"PLATFORM_DESTROY_LISTENERS",
177177
"PLATFORM_ID",
178178
"PLATFORM_INITIALIZER",
179-
"PLATFORM_SERVER_ID",
180179
"PREORDER_HOOK_FLAGS",
181180
"PRESERVE_HOST_CONTENT",
182181
"PRESERVE_HOST_CONTENT_DEFAULT",
@@ -602,7 +601,6 @@
602601
"isLView",
603602
"isNotFound",
604603
"isObserver",
605-
"isPlatformServer",
606604
"isPositive",
607605
"isPromise",
608606
"isPromise2",

packages/core/test/bundling/router/bundle.golden_symbols.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@
214214
"PLATFORM_DESTROY_LISTENERS",
215215
"PLATFORM_ID",
216216
"PLATFORM_INITIALIZER",
217-
"PLATFORM_SERVER_ID",
218217
"PREORDER_HOOK_FLAGS",
219218
"PRESERVE_HOST_CONTENT",
220219
"PRESERVE_HOST_CONTENT_DEFAULT",
@@ -840,7 +839,6 @@
840839
"isObservable",
841840
"isObserver",
842841
"isPOJO",
843-
"isPlatformServer",
844842
"isPositive",
845843
"isPromise",
846844
"isPromise2",

packages/core/test/bundling/standalone_bootstrap/bundle.golden_symbols.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@
147147
"PLATFORM_DESTROY_LISTENERS",
148148
"PLATFORM_ID",
149149
"PLATFORM_INITIALIZER",
150-
"PLATFORM_SERVER_ID",
151150
"PREORDER_HOOK_FLAGS",
152151
"PRESERVE_HOST_CONTENT",
153152
"PRESERVE_HOST_CONTENT_DEFAULT",
@@ -482,7 +481,6 @@
482481
"isLView",
483482
"isNotFound",
484483
"isObserver",
485-
"isPlatformServer",
486484
"isPositive",
487485
"isPromise",
488486
"isRefreshingViews",

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {DOCUMENT, isPlatformServer} from '@angular/common';
9+
import {DOCUMENT} from '@angular/common';
1010
import {
1111
APP_ID,
1212
CSP_NONCE,
@@ -114,6 +114,10 @@ export class SharedStylesHost implements OnDestroy {
114114
* External styles typically originate from the `ɵɵExternalStylesFeature` of a rendered component.
115115
*/
116116
private readonly external = new Map<string /** URL */, UsageRecord<HTMLLinkElement>>();
117+
118+
/**
119+
* Set of host DOM nodes that will have styles attached.
120+
*/
117121
private readonly hosts = new Set<Node>();
118122
private readonly shadowRoots: Node[] = [];
119123

@@ -123,7 +127,7 @@ export class SharedStylesHost implements OnDestroy {
123127
@Inject(CSP_NONCE) @Optional() private readonly nonce?: string | null,
124128
// Cannot remove it due to backward compatibility
125129
// (it seems some TGP targets might be calling this constructor directly).
126-
@Inject(PLATFORM_ID) private readonly platformId: object = {},
130+
@Inject(PLATFORM_ID) platformId: object = {},
127131
) {
128132
addServerStyles(doc, appId, this.inline, this.external);
129133
this.hosts.add(doc.head);
@@ -236,9 +240,9 @@ export class SharedStylesHost implements OnDestroy {
236240
if (this.nonce) {
237241
element.setAttribute('nonce', this.nonce);
238242
}
239-
// The `ng-app-id` attribute is used on the server to identify which styles were
240-
// created by the server renderer.
241-
if (isPlatformServer(this.platformId) && host === this.doc.head) {
243+
244+
// Add application identifier when on the server to support client-side reuse
245+
if (typeof ngServerMode !== 'undefined' && ngServerMode && host === this.doc.head) {
242246
element.setAttribute(APP_ID_ATTRIBUTE_NAME, this.appId);
243247
}
244248
host.appendChild(element);

0 commit comments

Comments
 (0)