@angular/platform-browser 21.0.0-next.8 → 21.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,308 +1,331 @@
1
1
  /**
2
- * @license Angular v21.0.0-next.8
2
+ * @license Angular v21.0.0-rc.0
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import { DOCUMENT, ɵgetDOM as _getDOM } from '@angular/common';
8
8
  import * as i0 from '@angular/core';
9
- import { InjectionToken, ɵRuntimeError as _RuntimeError, Injectable, Inject, APP_ID, CSP_NONCE, PLATFORM_ID, Optional, ViewEncapsulation, ɵTracingService as _TracingService, RendererStyleFlags2, ɵallLeavingAnimations as _allLeavingAnimations } from '@angular/core';
9
+ import { Injectable, Inject, InjectionToken, ɵRuntimeError as _RuntimeError, APP_ID, CSP_NONCE, PLATFORM_ID, Optional, ViewEncapsulation, ɵTracingService as _TracingService, RendererStyleFlags2, ɵallLeavingAnimations as _allLeavingAnimations } from '@angular/core';
10
+
11
+ class EventManagerPlugin {
12
+ _doc;
13
+ constructor(_doc) {
14
+ this._doc = _doc;
15
+ }
16
+ manager;
17
+ }
18
+
19
+ class DomEventsPlugin extends EventManagerPlugin {
20
+ constructor(doc) {
21
+ super(doc);
22
+ }
23
+ supports(eventName) {
24
+ return true;
25
+ }
26
+ addEventListener(element, eventName, handler, options) {
27
+ element.addEventListener(eventName, handler, options);
28
+ return () => this.removeEventListener(element, eventName, handler, options);
29
+ }
30
+ removeEventListener(target, eventName, callback, options) {
31
+ return target.removeEventListener(eventName, callback, options);
32
+ }
33
+ static ɵfac = i0.ɵɵngDeclareFactory({
34
+ minVersion: "12.0.0",
35
+ version: "21.0.0-rc.0",
36
+ ngImport: i0,
37
+ type: DomEventsPlugin,
38
+ deps: [{
39
+ token: DOCUMENT
40
+ }],
41
+ target: i0.ɵɵFactoryTarget.Injectable
42
+ });
43
+ static ɵprov = i0.ɵɵngDeclareInjectable({
44
+ minVersion: "12.0.0",
45
+ version: "21.0.0-rc.0",
46
+ ngImport: i0,
47
+ type: DomEventsPlugin
48
+ });
49
+ }
50
+ i0.ɵɵngDeclareClassMetadata({
51
+ minVersion: "12.0.0",
52
+ version: "21.0.0-rc.0",
53
+ ngImport: i0,
54
+ type: DomEventsPlugin,
55
+ decorators: [{
56
+ type: Injectable
57
+ }],
58
+ ctorParameters: () => [{
59
+ type: undefined,
60
+ decorators: [{
61
+ type: Inject,
62
+ args: [DOCUMENT]
63
+ }]
64
+ }]
65
+ });
10
66
 
11
- /**
12
- * The injection token for plugins of the `EventManager` service.
13
- *
14
- * @publicApi
15
- */
16
67
  const EVENT_MANAGER_PLUGINS = new InjectionToken(typeof ngDevMode !== undefined && ngDevMode ? 'EventManagerPlugins' : '');
17
- /**
18
- * An injectable service that provides event management for Angular
19
- * through a browser plug-in.
20
- *
21
- * @publicApi
22
- */
23
68
  class EventManager {
24
- _zone;
25
- _plugins;
26
- _eventNameToPlugin = new Map();
27
- /**
28
- * Initializes an instance of the event-manager service.
29
- */
30
- constructor(plugins, _zone) {
31
- this._zone = _zone;
32
- plugins.forEach((plugin) => {
33
- plugin.manager = this;
34
- });
35
- this._plugins = plugins.slice().reverse();
36
- }
37
- /**
38
- * Registers a handler for a specific element and event.
39
- *
40
- * @param element The HTML element to receive event notifications.
41
- * @param eventName The name of the event to listen for.
42
- * @param handler A function to call when the notification occurs. Receives the
43
- * event object as an argument.
44
- * @param options Options that configure how the event listener is bound.
45
- * @returns A callback function that can be used to remove the handler.
46
- */
47
- addEventListener(element, eventName, handler, options) {
48
- const plugin = this._findPluginFor(eventName);
49
- return plugin.addEventListener(element, eventName, handler, options);
50
- }
51
- /**
52
- * Retrieves the compilation zone in which event listeners are registered.
53
- */
54
- getZone() {
55
- return this._zone;
56
- }
57
- /** @internal */
58
- _findPluginFor(eventName) {
59
- let plugin = this._eventNameToPlugin.get(eventName);
60
- if (plugin) {
61
- return plugin;
62
- }
63
- const plugins = this._plugins;
64
- plugin = plugins.find((plugin) => plugin.supports(eventName));
65
- if (!plugin) {
66
- throw new _RuntimeError(5101 /* RuntimeErrorCode.NO_PLUGIN_FOR_EVENT */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
67
- `No event manager plugin found for event ${eventName}`);
68
- }
69
- this._eventNameToPlugin.set(eventName, plugin);
70
- return plugin;
71
- }
72
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.8", ngImport: i0, type: EventManager, deps: [{ token: EVENT_MANAGER_PLUGINS }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
73
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.8", ngImport: i0, type: EventManager });
74
- }
75
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.8", ngImport: i0, type: EventManager, decorators: [{
76
- type: Injectable
77
- }], ctorParameters: () => [{ type: undefined, decorators: [{
78
- type: Inject,
79
- args: [EVENT_MANAGER_PLUGINS]
80
- }] }, { type: i0.NgZone }] });
81
- /**
82
- * The plugin definition for the `EventManager` class
83
- *
84
- * It can be used as a base class to create custom manager plugins, i.e. you can create your own
85
- * class that extends the `EventManagerPlugin` one.
86
- *
87
- * @publicApi
88
- */
89
- class EventManagerPlugin {
90
- _doc;
91
- // TODO: remove (has some usage in G3)
92
- constructor(_doc) {
93
- this._doc = _doc;
94
- }
95
- // Using non-null assertion because it's set by EventManager's constructor
96
- manager;
69
+ _zone;
70
+ _plugins;
71
+ _eventNameToPlugin = new Map();
72
+ constructor(plugins, _zone) {
73
+ this._zone = _zone;
74
+ plugins.forEach(plugin => {
75
+ plugin.manager = this;
76
+ });
77
+ const otherPlugins = plugins.filter(p => !(p instanceof DomEventsPlugin));
78
+ this._plugins = otherPlugins.slice().reverse();
79
+ const domEventPlugin = plugins.find(p => p instanceof DomEventsPlugin);
80
+ if (domEventPlugin) {
81
+ this._plugins.push(domEventPlugin);
82
+ }
83
+ }
84
+ addEventListener(element, eventName, handler, options) {
85
+ const plugin = this._findPluginFor(eventName);
86
+ return plugin.addEventListener(element, eventName, handler, options);
87
+ }
88
+ getZone() {
89
+ return this._zone;
90
+ }
91
+ _findPluginFor(eventName) {
92
+ let plugin = this._eventNameToPlugin.get(eventName);
93
+ if (plugin) {
94
+ return plugin;
95
+ }
96
+ const plugins = this._plugins;
97
+ plugin = plugins.find(plugin => plugin.supports(eventName));
98
+ if (!plugin) {
99
+ throw new _RuntimeError(5101, (typeof ngDevMode === 'undefined' || ngDevMode) && `No event manager plugin found for event ${eventName}`);
100
+ }
101
+ this._eventNameToPlugin.set(eventName, plugin);
102
+ return plugin;
103
+ }
104
+ static ɵfac = i0.ɵɵngDeclareFactory({
105
+ minVersion: "12.0.0",
106
+ version: "21.0.0-rc.0",
107
+ ngImport: i0,
108
+ type: EventManager,
109
+ deps: [{
110
+ token: EVENT_MANAGER_PLUGINS
111
+ }, {
112
+ token: i0.NgZone
113
+ }],
114
+ target: i0.ɵɵFactoryTarget.Injectable
115
+ });
116
+ static ɵprov = i0.ɵɵngDeclareInjectable({
117
+ minVersion: "12.0.0",
118
+ version: "21.0.0-rc.0",
119
+ ngImport: i0,
120
+ type: EventManager
121
+ });
97
122
  }
123
+ i0.ɵɵngDeclareClassMetadata({
124
+ minVersion: "12.0.0",
125
+ version: "21.0.0-rc.0",
126
+ ngImport: i0,
127
+ type: EventManager,
128
+ decorators: [{
129
+ type: Injectable
130
+ }],
131
+ ctorParameters: () => [{
132
+ type: undefined,
133
+ decorators: [{
134
+ type: Inject,
135
+ args: [EVENT_MANAGER_PLUGINS]
136
+ }]
137
+ }, {
138
+ type: i0.NgZone
139
+ }]
140
+ });
98
141
 
99
- /** The style elements attribute name used to set value of `APP_ID` token. */
100
142
  const APP_ID_ATTRIBUTE_NAME = 'ng-app-id';
101
- /**
102
- * Removes all provided elements from the document.
103
- * @param elements An array of HTML Elements.
104
- */
105
143
  function removeElements(elements) {
106
- for (const element of elements) {
107
- element.remove();
108
- }
144
+ for (const element of elements) {
145
+ element.remove();
146
+ }
109
147
  }
110
- /**
111
- * Creates a `style` element with the provided inline style content.
112
- * @param style A string of the inline style content.
113
- * @param doc A DOM Document to use to create the element.
114
- * @returns An HTMLStyleElement instance.
115
- */
116
148
  function createStyleElement(style, doc) {
117
- const styleElement = doc.createElement('style');
118
- styleElement.textContent = style;
119
- return styleElement;
149
+ const styleElement = doc.createElement('style');
150
+ styleElement.textContent = style;
151
+ return styleElement;
120
152
  }
121
- /**
122
- * Searches a DOM document's head element for style elements with a matching application
123
- * identifier attribute (`ng-app-id`) to the provide identifier and adds usage records for each.
124
- * @param doc An HTML DOM document instance.
125
- * @param appId A string containing an Angular application identifer.
126
- * @param inline A Map object for tracking inline (defined via `styles` in component decorator) style usage.
127
- * @param external A Map object for tracking external (defined via `styleUrls` in component decorator) style usage.
128
- */
129
153
  function addServerStyles(doc, appId, inline, external) {
130
- const elements = doc.head?.querySelectorAll(`style[${APP_ID_ATTRIBUTE_NAME}="${appId}"],link[${APP_ID_ATTRIBUTE_NAME}="${appId}"]`);
131
- if (elements) {
132
- for (const styleElement of elements) {
133
- styleElement.removeAttribute(APP_ID_ATTRIBUTE_NAME);
134
- if (styleElement instanceof HTMLLinkElement) {
135
- // Only use filename from href
136
- // The href is build time generated with a unique value to prevent duplicates.
137
- external.set(styleElement.href.slice(styleElement.href.lastIndexOf('/') + 1), {
138
- usage: 0,
139
- elements: [styleElement],
140
- });
141
- }
142
- else if (styleElement.textContent) {
143
- inline.set(styleElement.textContent, { usage: 0, elements: [styleElement] });
144
- }
145
- }
154
+ const elements = doc.head?.querySelectorAll(`style[${APP_ID_ATTRIBUTE_NAME}="${appId}"],link[${APP_ID_ATTRIBUTE_NAME}="${appId}"]`);
155
+ if (elements) {
156
+ for (const styleElement of elements) {
157
+ styleElement.removeAttribute(APP_ID_ATTRIBUTE_NAME);
158
+ if (styleElement instanceof HTMLLinkElement) {
159
+ external.set(styleElement.href.slice(styleElement.href.lastIndexOf('/') + 1), {
160
+ usage: 0,
161
+ elements: [styleElement]
162
+ });
163
+ } else if (styleElement.textContent) {
164
+ inline.set(styleElement.textContent, {
165
+ usage: 0,
166
+ elements: [styleElement]
167
+ });
168
+ }
146
169
  }
170
+ }
147
171
  }
148
- /**
149
- * Creates a `link` element for the provided external style URL.
150
- * @param url A string of the URL for the stylesheet.
151
- * @param doc A DOM Document to use to create the element.
152
- * @returns An HTMLLinkElement instance.
153
- */
154
172
  function createLinkElement(url, doc) {
155
- const linkElement = doc.createElement('link');
156
- linkElement.setAttribute('rel', 'stylesheet');
157
- linkElement.setAttribute('href', url);
158
- return linkElement;
173
+ const linkElement = doc.createElement('link');
174
+ linkElement.setAttribute('rel', 'stylesheet');
175
+ linkElement.setAttribute('href', url);
176
+ return linkElement;
159
177
  }
160
178
  class SharedStylesHost {
161
- doc;
162
- appId;
163
- nonce;
164
- /**
165
- * Provides usage information for active inline style content and associated HTML <style> elements.
166
- * Embedded styles typically originate from the `styles` metadata of a rendered component.
167
- */
168
- inline = new Map();
169
- /**
170
- * Provides usage information for active external style URLs and the associated HTML <link> elements.
171
- * External styles typically originate from the `ɵɵExternalStylesFeature` of a rendered component.
172
- */
173
- external = new Map();
174
- /**
175
- * Set of host DOM nodes that will have styles attached.
176
- */
177
- hosts = new Set();
178
- constructor(doc, appId, nonce,
179
- // Cannot remove it due to backward compatibility
180
- // (it seems some TGP targets might be calling this constructor directly).
181
- platformId = {}) {
182
- this.doc = doc;
183
- this.appId = appId;
184
- this.nonce = nonce;
185
- addServerStyles(doc, appId, this.inline, this.external);
186
- this.hosts.add(doc.head);
187
- }
188
- /**
189
- * Adds embedded styles to the DOM via HTML `style` elements.
190
- * @param styles An array of style content strings.
191
- */
192
- addStyles(styles, urls) {
193
- for (const value of styles) {
194
- this.addUsage(value, this.inline, createStyleElement);
195
- }
196
- urls?.forEach((value) => this.addUsage(value, this.external, createLinkElement));
197
- }
198
- /**
199
- * Removes embedded styles from the DOM that were added as HTML `style` elements.
200
- * @param styles An array of style content strings.
201
- */
202
- removeStyles(styles, urls) {
203
- for (const value of styles) {
204
- this.removeUsage(value, this.inline);
205
- }
206
- urls?.forEach((value) => this.removeUsage(value, this.external));
207
- }
208
- addUsage(value, usages, creator) {
209
- // Attempt to get any current usage of the value
210
- const record = usages.get(value);
211
- // If existing, just increment the usage count
212
- if (record) {
213
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && record.usage === 0) {
214
- // A usage count of zero indicates a preexisting server generated style.
215
- // This attribute is solely used for debugging purposes of SSR style reuse.
216
- record.elements.forEach((element) => element.setAttribute('ng-style-reused', ''));
217
- }
218
- record.usage++;
219
- }
220
- else {
221
- // Otherwise, create an entry to track the elements and add element for each host
222
- usages.set(value, {
223
- usage: 1,
224
- elements: [...this.hosts].map((host) => this.addElement(host, creator(value, this.doc))),
225
- });
226
- }
227
- }
228
- removeUsage(value, usages) {
229
- // Attempt to get any current usage of the value
230
- const record = usages.get(value);
231
- // If there is a record, reduce the usage count and if no longer used,
232
- // remove from DOM and delete usage record.
233
- if (record) {
234
- record.usage--;
235
- if (record.usage <= 0) {
236
- removeElements(record.elements);
237
- usages.delete(value);
238
- }
239
- }
240
- }
241
- ngOnDestroy() {
242
- for (const [, { elements }] of [...this.inline, ...this.external]) {
243
- removeElements(elements);
244
- }
245
- this.hosts.clear();
246
- }
247
- /**
248
- * Adds a host node to the set of style hosts and adds all existing style usage to
249
- * the newly added host node.
250
- *
251
- * This is currently only used for Shadow DOM encapsulation mode.
252
- */
253
- addHost(hostNode) {
254
- this.hosts.add(hostNode);
255
- // Add existing styles to new host
256
- for (const [style, { elements }] of this.inline) {
257
- elements.push(this.addElement(hostNode, createStyleElement(style, this.doc)));
258
- }
259
- for (const [url, { elements }] of this.external) {
260
- elements.push(this.addElement(hostNode, createLinkElement(url, this.doc)));
261
- }
262
- }
263
- removeHost(hostNode) {
264
- this.hosts.delete(hostNode);
265
- }
266
- addElement(host, element) {
267
- // Add a nonce if present
268
- if (this.nonce) {
269
- element.setAttribute('nonce', this.nonce);
270
- }
271
- // Add application identifier when on the server to support client-side reuse
272
- if (typeof ngServerMode !== 'undefined' && ngServerMode) {
273
- element.setAttribute(APP_ID_ATTRIBUTE_NAME, this.appId);
274
- }
275
- // Insert the element into the DOM with the host node as parent
276
- return host.appendChild(element);
277
- }
278
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.8", ngImport: i0, type: SharedStylesHost, deps: [{ token: DOCUMENT }, { token: APP_ID }, { token: CSP_NONCE, optional: true }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
279
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.8", ngImport: i0, type: SharedStylesHost });
179
+ doc;
180
+ appId;
181
+ nonce;
182
+ inline = new Map();
183
+ external = new Map();
184
+ hosts = new Set();
185
+ constructor(doc, appId, nonce, platformId = {}) {
186
+ this.doc = doc;
187
+ this.appId = appId;
188
+ this.nonce = nonce;
189
+ addServerStyles(doc, appId, this.inline, this.external);
190
+ this.hosts.add(doc.head);
191
+ }
192
+ addStyles(styles, urls) {
193
+ for (const value of styles) {
194
+ this.addUsage(value, this.inline, createStyleElement);
195
+ }
196
+ urls?.forEach(value => this.addUsage(value, this.external, createLinkElement));
197
+ }
198
+ removeStyles(styles, urls) {
199
+ for (const value of styles) {
200
+ this.removeUsage(value, this.inline);
201
+ }
202
+ urls?.forEach(value => this.removeUsage(value, this.external));
203
+ }
204
+ addUsage(value, usages, creator) {
205
+ const record = usages.get(value);
206
+ if (record) {
207
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) && record.usage === 0) {
208
+ record.elements.forEach(element => element.setAttribute('ng-style-reused', ''));
209
+ }
210
+ record.usage++;
211
+ } else {
212
+ usages.set(value, {
213
+ usage: 1,
214
+ elements: [...this.hosts].map(host => this.addElement(host, creator(value, this.doc)))
215
+ });
216
+ }
217
+ }
218
+ removeUsage(value, usages) {
219
+ const record = usages.get(value);
220
+ if (record) {
221
+ record.usage--;
222
+ if (record.usage <= 0) {
223
+ removeElements(record.elements);
224
+ usages.delete(value);
225
+ }
226
+ }
227
+ }
228
+ ngOnDestroy() {
229
+ for (const [, {
230
+ elements
231
+ }] of [...this.inline, ...this.external]) {
232
+ removeElements(elements);
233
+ }
234
+ this.hosts.clear();
235
+ }
236
+ addHost(hostNode) {
237
+ this.hosts.add(hostNode);
238
+ for (const [style, {
239
+ elements
240
+ }] of this.inline) {
241
+ elements.push(this.addElement(hostNode, createStyleElement(style, this.doc)));
242
+ }
243
+ for (const [url, {
244
+ elements
245
+ }] of this.external) {
246
+ elements.push(this.addElement(hostNode, createLinkElement(url, this.doc)));
247
+ }
248
+ }
249
+ removeHost(hostNode) {
250
+ this.hosts.delete(hostNode);
251
+ }
252
+ addElement(host, element) {
253
+ if (this.nonce) {
254
+ element.setAttribute('nonce', this.nonce);
255
+ }
256
+ if (typeof ngServerMode !== 'undefined' && ngServerMode) {
257
+ element.setAttribute(APP_ID_ATTRIBUTE_NAME, this.appId);
258
+ }
259
+ return host.appendChild(element);
260
+ }
261
+ static ɵfac = i0.ɵɵngDeclareFactory({
262
+ minVersion: "12.0.0",
263
+ version: "21.0.0-rc.0",
264
+ ngImport: i0,
265
+ type: SharedStylesHost,
266
+ deps: [{
267
+ token: DOCUMENT
268
+ }, {
269
+ token: APP_ID
270
+ }, {
271
+ token: CSP_NONCE,
272
+ optional: true
273
+ }, {
274
+ token: PLATFORM_ID
275
+ }],
276
+ target: i0.ɵɵFactoryTarget.Injectable
277
+ });
278
+ static ɵprov = i0.ɵɵngDeclareInjectable({
279
+ minVersion: "12.0.0",
280
+ version: "21.0.0-rc.0",
281
+ ngImport: i0,
282
+ type: SharedStylesHost
283
+ });
280
284
  }
281
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.8", ngImport: i0, type: SharedStylesHost, decorators: [{
282
- type: Injectable
283
- }], ctorParameters: () => [{ type: Document, decorators: [{
284
- type: Inject,
285
- args: [DOCUMENT]
286
- }] }, { type: undefined, decorators: [{
287
- type: Inject,
288
- args: [APP_ID]
289
- }] }, { type: undefined, decorators: [{
290
- type: Inject,
291
- args: [CSP_NONCE]
292
- }, {
293
- type: Optional
294
- }] }, { type: undefined, decorators: [{
295
- type: Inject,
296
- args: [PLATFORM_ID]
297
- }] }] });
285
+ i0.ɵɵngDeclareClassMetadata({
286
+ minVersion: "12.0.0",
287
+ version: "21.0.0-rc.0",
288
+ ngImport: i0,
289
+ type: SharedStylesHost,
290
+ decorators: [{
291
+ type: Injectable
292
+ }],
293
+ ctorParameters: () => [{
294
+ type: Document,
295
+ decorators: [{
296
+ type: Inject,
297
+ args: [DOCUMENT]
298
+ }]
299
+ }, {
300
+ type: undefined,
301
+ decorators: [{
302
+ type: Inject,
303
+ args: [APP_ID]
304
+ }]
305
+ }, {
306
+ type: undefined,
307
+ decorators: [{
308
+ type: Inject,
309
+ args: [CSP_NONCE]
310
+ }, {
311
+ type: Optional
312
+ }]
313
+ }, {
314
+ type: undefined,
315
+ decorators: [{
316
+ type: Inject,
317
+ args: [PLATFORM_ID]
318
+ }]
319
+ }]
320
+ });
298
321
 
299
322
  const NAMESPACE_URIS = {
300
- 'svg': 'http://www.w3.org/2000/svg',
301
- 'xhtml': 'http://www.w3.org/1999/xhtml',
302
- 'xlink': 'http://www.w3.org/1999/xlink',
303
- 'xml': 'http://www.w3.org/XML/1998/namespace',
304
- 'xmlns': 'http://www.w3.org/2000/xmlns/',
305
- 'math': 'http://www.w3.org/1998/Math/MathML',
323
+ 'svg': 'http://www.w3.org/2000/svg',
324
+ 'xhtml': 'http://www.w3.org/1999/xhtml',
325
+ 'xlink': 'http://www.w3.org/1999/xlink',
326
+ 'xml': 'http://www.w3.org/XML/1998/namespace',
327
+ 'xmlns': 'http://www.w3.org/2000/xmlns/',
328
+ 'math': 'http://www.w3.org/1998/Math/MathML'
306
329
  };
307
330
  const COMPONENT_REGEX = /%COMP%/g;
308
331
  const SOURCEMAP_URL_REGEXP = /\/\*#\s*sourceMappingURL=(.+?)\s*\*\//;
@@ -310,486 +333,464 @@ const PROTOCOL_REGEXP = /^https?:/;
310
333
  const COMPONENT_VARIABLE = '%COMP%';
311
334
  const HOST_ATTR = `_nghost-${COMPONENT_VARIABLE}`;
312
335
  const CONTENT_ATTR = `_ngcontent-${COMPONENT_VARIABLE}`;
313
- /**
314
- * The default value for the `REMOVE_STYLES_ON_COMPONENT_DESTROY` DI token.
315
- */
316
336
  const REMOVE_STYLES_ON_COMPONENT_DESTROY_DEFAULT = true;
317
- /**
318
- * A DI token that indicates whether styles
319
- * of destroyed components should be removed from DOM.
320
- *
321
- * By default, the value is set to `true`.
322
- * @publicApi
323
- */
324
337
  const REMOVE_STYLES_ON_COMPONENT_DESTROY = new InjectionToken(typeof ngDevMode !== undefined && ngDevMode ? 'RemoveStylesOnCompDestroy' : '', {
325
- providedIn: 'root',
326
- factory: () => REMOVE_STYLES_ON_COMPONENT_DESTROY_DEFAULT,
338
+ providedIn: 'root',
339
+ factory: () => REMOVE_STYLES_ON_COMPONENT_DESTROY_DEFAULT
327
340
  });
328
341
  function shimContentAttribute(componentShortId) {
329
- return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
342
+ return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
330
343
  }
331
344
  function shimHostAttribute(componentShortId) {
332
- return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
345
+ return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
333
346
  }
334
347
  function shimStylesContent(compId, styles) {
335
- return styles.map((s) => s.replace(COMPONENT_REGEX, compId));
348
+ return styles.map(s => s.replace(COMPONENT_REGEX, compId));
336
349
  }
337
- /**
338
- * Prepends a baseHref to the `sourceMappingURL` within the provided CSS content.
339
- * If the `sourceMappingURL` contains an inline (encoded) map, the function skips processing.
340
- *
341
- * @note For inline stylesheets, the `sourceMappingURL` is relative to the page's origin
342
- * and not the provided baseHref. This function is needed as when accessing the page with a URL
343
- * containing two or more segments.
344
- * For example, if the baseHref is set to `/`, and you visit a URL like `http://localhost/foo/bar`,
345
- * the map would be requested from `http://localhost/foo/bar/comp.css.map` instead of what you'd expect,
346
- * which is `http://localhost/comp.css.map`. This behavior is corrected by modifying the `sourceMappingURL`
347
- * to ensure external source maps are loaded relative to the baseHref.
348
- *
349
-
350
- * @param baseHref - The base URL to prepend to the `sourceMappingURL`.
351
- * @param styles - An array of CSS content strings, each potentially containing a `sourceMappingURL`.
352
- * @returns The updated array of CSS content strings with modified `sourceMappingURL` values,
353
- * or the original content if no modification is needed.
354
- */
355
350
  function addBaseHrefToCssSourceMap(baseHref, styles) {
356
- if (!baseHref) {
357
- return styles;
358
- }
359
- const absoluteBaseHrefUrl = new URL(baseHref, 'http://localhost');
360
- return styles.map((cssContent) => {
361
- if (!cssContent.includes('sourceMappingURL=')) {
362
- return cssContent;
363
- }
364
- return cssContent.replace(SOURCEMAP_URL_REGEXP, (_, sourceMapUrl) => {
365
- if (sourceMapUrl[0] === '/' ||
366
- sourceMapUrl.startsWith('data:') ||
367
- PROTOCOL_REGEXP.test(sourceMapUrl)) {
368
- return `/*# sourceMappingURL=${sourceMapUrl} */`;
369
- }
370
- const { pathname: resolvedSourceMapUrl } = new URL(sourceMapUrl, absoluteBaseHrefUrl);
371
- return `/*# sourceMappingURL=${resolvedSourceMapUrl} */`;
372
- });
351
+ if (!baseHref) {
352
+ return styles;
353
+ }
354
+ const absoluteBaseHrefUrl = new URL(baseHref, 'http://localhost');
355
+ return styles.map(cssContent => {
356
+ if (!cssContent.includes('sourceMappingURL=')) {
357
+ return cssContent;
358
+ }
359
+ return cssContent.replace(SOURCEMAP_URL_REGEXP, (_, sourceMapUrl) => {
360
+ if (sourceMapUrl[0] === '/' || sourceMapUrl.startsWith('data:') || PROTOCOL_REGEXP.test(sourceMapUrl)) {
361
+ return `/*# sourceMappingURL=${sourceMapUrl} */`;
362
+ }
363
+ const {
364
+ pathname: resolvedSourceMapUrl
365
+ } = new URL(sourceMapUrl, absoluteBaseHrefUrl);
366
+ return `/*# sourceMappingURL=${resolvedSourceMapUrl} */`;
373
367
  });
368
+ });
374
369
  }
375
370
  class DomRendererFactory2 {
376
- eventManager;
377
- sharedStylesHost;
378
- appId;
379
- removeStylesOnCompDestroy;
380
- doc;
381
- platformId;
382
- ngZone;
383
- nonce;
384
- tracingService;
385
- rendererByCompId = new Map();
386
- defaultRenderer;
387
- platformIsServer;
388
- constructor(eventManager, sharedStylesHost, appId, removeStylesOnCompDestroy, doc, platformId, ngZone, nonce = null, tracingService = null) {
389
- this.eventManager = eventManager;
390
- this.sharedStylesHost = sharedStylesHost;
391
- this.appId = appId;
392
- this.removeStylesOnCompDestroy = removeStylesOnCompDestroy;
393
- this.doc = doc;
394
- this.platformId = platformId;
395
- this.ngZone = ngZone;
396
- this.nonce = nonce;
397
- this.tracingService = tracingService;
398
- this.platformIsServer = typeof ngServerMode !== 'undefined' && ngServerMode;
399
- this.defaultRenderer = new DefaultDomRenderer2(eventManager, doc, ngZone, this.platformIsServer, this.tracingService);
400
- }
401
- createRenderer(element, type) {
402
- if (!element || !type) {
403
- return this.defaultRenderer;
404
- }
405
- if (typeof ngServerMode !== 'undefined' &&
406
- ngServerMode &&
407
- (type.encapsulation === ViewEncapsulation.ShadowDom ||
408
- type.encapsulation === ViewEncapsulation.IsolatedShadowDom)) {
409
- // Domino does not support shadow DOM.
410
- type = { ...type, encapsulation: ViewEncapsulation.Emulated };
411
- }
412
- const renderer = this.getOrCreateRenderer(element, type);
413
- // Renderers have different logic due to different encapsulation behaviours.
414
- // Ex: for emulated, an attribute is added to the element.
415
- if (renderer instanceof EmulatedEncapsulationDomRenderer2) {
416
- renderer.applyToHost(element);
417
- }
418
- else if (renderer instanceof NoneEncapsulationDomRenderer) {
419
- renderer.applyStyles();
420
- }
421
- return renderer;
422
- }
423
- getOrCreateRenderer(element, type) {
424
- const rendererByCompId = this.rendererByCompId;
425
- let renderer = rendererByCompId.get(type.id);
426
- if (!renderer) {
427
- const doc = this.doc;
428
- const ngZone = this.ngZone;
429
- const eventManager = this.eventManager;
430
- const sharedStylesHost = this.sharedStylesHost;
431
- const removeStylesOnCompDestroy = this.removeStylesOnCompDestroy;
432
- const platformIsServer = this.platformIsServer;
433
- const tracingService = this.tracingService;
434
- switch (type.encapsulation) {
435
- case ViewEncapsulation.Emulated:
436
- renderer = new EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, type, this.appId, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService);
437
- break;
438
- case ViewEncapsulation.ShadowDom:
439
- return new ShadowDomRenderer(eventManager, element, type, doc, ngZone, this.nonce, platformIsServer, tracingService, sharedStylesHost);
440
- case ViewEncapsulation.IsolatedShadowDom:
441
- return new ShadowDomRenderer(eventManager, element, type, doc, ngZone, this.nonce, platformIsServer, tracingService);
442
- default:
443
- renderer = new NoneEncapsulationDomRenderer(eventManager, sharedStylesHost, type, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService);
444
- break;
445
- }
446
- rendererByCompId.set(type.id, renderer);
447
- }
448
- return renderer;
449
- }
450
- ngOnDestroy() {
451
- this.rendererByCompId.clear();
452
- }
453
- /**
454
- * Used during HMR to clear any cached data about a component.
455
- * @param componentId ID of the component that is being replaced.
456
- */
457
- componentReplaced(componentId) {
458
- this.rendererByCompId.delete(componentId);
459
- }
460
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.8", ngImport: i0, type: DomRendererFactory2, deps: [{ token: EventManager }, { token: SharedStylesHost }, { token: APP_ID }, { token: REMOVE_STYLES_ON_COMPONENT_DESTROY }, { token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.NgZone }, { token: CSP_NONCE }, { token: _TracingService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
461
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.8", ngImport: i0, type: DomRendererFactory2 });
371
+ eventManager;
372
+ sharedStylesHost;
373
+ appId;
374
+ removeStylesOnCompDestroy;
375
+ doc;
376
+ platformId;
377
+ ngZone;
378
+ nonce;
379
+ tracingService;
380
+ rendererByCompId = new Map();
381
+ defaultRenderer;
382
+ platformIsServer;
383
+ constructor(eventManager, sharedStylesHost, appId, removeStylesOnCompDestroy, doc, platformId, ngZone, nonce = null, tracingService = null) {
384
+ this.eventManager = eventManager;
385
+ this.sharedStylesHost = sharedStylesHost;
386
+ this.appId = appId;
387
+ this.removeStylesOnCompDestroy = removeStylesOnCompDestroy;
388
+ this.doc = doc;
389
+ this.platformId = platformId;
390
+ this.ngZone = ngZone;
391
+ this.nonce = nonce;
392
+ this.tracingService = tracingService;
393
+ this.platformIsServer = typeof ngServerMode !== 'undefined' && ngServerMode;
394
+ this.defaultRenderer = new DefaultDomRenderer2(eventManager, doc, ngZone, this.platformIsServer, this.tracingService);
395
+ }
396
+ createRenderer(element, type) {
397
+ if (!element || !type) {
398
+ return this.defaultRenderer;
399
+ }
400
+ if (typeof ngServerMode !== 'undefined' && ngServerMode && (type.encapsulation === ViewEncapsulation.ShadowDom || type.encapsulation === ViewEncapsulation.IsolatedShadowDom)) {
401
+ type = {
402
+ ...type,
403
+ encapsulation: ViewEncapsulation.Emulated
404
+ };
405
+ }
406
+ const renderer = this.getOrCreateRenderer(element, type);
407
+ if (renderer instanceof EmulatedEncapsulationDomRenderer2) {
408
+ renderer.applyToHost(element);
409
+ } else if (renderer instanceof NoneEncapsulationDomRenderer) {
410
+ renderer.applyStyles();
411
+ }
412
+ return renderer;
413
+ }
414
+ getOrCreateRenderer(element, type) {
415
+ const rendererByCompId = this.rendererByCompId;
416
+ let renderer = rendererByCompId.get(type.id);
417
+ if (!renderer) {
418
+ const doc = this.doc;
419
+ const ngZone = this.ngZone;
420
+ const eventManager = this.eventManager;
421
+ const sharedStylesHost = this.sharedStylesHost;
422
+ const removeStylesOnCompDestroy = this.removeStylesOnCompDestroy;
423
+ const platformIsServer = this.platformIsServer;
424
+ const tracingService = this.tracingService;
425
+ switch (type.encapsulation) {
426
+ case ViewEncapsulation.Emulated:
427
+ renderer = new EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, type, this.appId, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService);
428
+ break;
429
+ case ViewEncapsulation.ShadowDom:
430
+ return new ShadowDomRenderer(eventManager, element, type, doc, ngZone, this.nonce, platformIsServer, tracingService, sharedStylesHost);
431
+ case ViewEncapsulation.IsolatedShadowDom:
432
+ return new ShadowDomRenderer(eventManager, element, type, doc, ngZone, this.nonce, platformIsServer, tracingService);
433
+ default:
434
+ renderer = new NoneEncapsulationDomRenderer(eventManager, sharedStylesHost, type, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService);
435
+ break;
436
+ }
437
+ rendererByCompId.set(type.id, renderer);
438
+ }
439
+ return renderer;
440
+ }
441
+ ngOnDestroy() {
442
+ this.rendererByCompId.clear();
443
+ }
444
+ componentReplaced(componentId) {
445
+ this.rendererByCompId.delete(componentId);
446
+ }
447
+ static ɵfac = i0.ɵɵngDeclareFactory({
448
+ minVersion: "12.0.0",
449
+ version: "21.0.0-rc.0",
450
+ ngImport: i0,
451
+ type: DomRendererFactory2,
452
+ deps: [{
453
+ token: EventManager
454
+ }, {
455
+ token: SharedStylesHost
456
+ }, {
457
+ token: APP_ID
458
+ }, {
459
+ token: REMOVE_STYLES_ON_COMPONENT_DESTROY
460
+ }, {
461
+ token: DOCUMENT
462
+ }, {
463
+ token: PLATFORM_ID
464
+ }, {
465
+ token: i0.NgZone
466
+ }, {
467
+ token: CSP_NONCE
468
+ }, {
469
+ token: _TracingService,
470
+ optional: true
471
+ }],
472
+ target: i0.ɵɵFactoryTarget.Injectable
473
+ });
474
+ static ɵprov = i0.ɵɵngDeclareInjectable({
475
+ minVersion: "12.0.0",
476
+ version: "21.0.0-rc.0",
477
+ ngImport: i0,
478
+ type: DomRendererFactory2
479
+ });
462
480
  }
463
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0-next.8", ngImport: i0, type: DomRendererFactory2, decorators: [{
464
- type: Injectable
465
- }], ctorParameters: () => [{ type: EventManager }, { type: SharedStylesHost }, { type: undefined, decorators: [{
466
- type: Inject,
467
- args: [APP_ID]
468
- }] }, { type: undefined, decorators: [{
469
- type: Inject,
470
- args: [REMOVE_STYLES_ON_COMPONENT_DESTROY]
471
- }] }, { type: Document, decorators: [{
472
- type: Inject,
473
- args: [DOCUMENT]
474
- }] }, { type: Object, decorators: [{
475
- type: Inject,
476
- args: [PLATFORM_ID]
477
- }] }, { type: i0.NgZone }, { type: undefined, decorators: [{
478
- type: Inject,
479
- args: [CSP_NONCE]
480
- }] }, { type: i0.ɵTracingService, decorators: [{
481
- type: Inject,
482
- args: [_TracingService]
483
- }, {
484
- type: Optional
485
- }] }] });
481
+ i0.ɵɵngDeclareClassMetadata({
482
+ minVersion: "12.0.0",
483
+ version: "21.0.0-rc.0",
484
+ ngImport: i0,
485
+ type: DomRendererFactory2,
486
+ decorators: [{
487
+ type: Injectable
488
+ }],
489
+ ctorParameters: () => [{
490
+ type: EventManager
491
+ }, {
492
+ type: SharedStylesHost
493
+ }, {
494
+ type: undefined,
495
+ decorators: [{
496
+ type: Inject,
497
+ args: [APP_ID]
498
+ }]
499
+ }, {
500
+ type: undefined,
501
+ decorators: [{
502
+ type: Inject,
503
+ args: [REMOVE_STYLES_ON_COMPONENT_DESTROY]
504
+ }]
505
+ }, {
506
+ type: Document,
507
+ decorators: [{
508
+ type: Inject,
509
+ args: [DOCUMENT]
510
+ }]
511
+ }, {
512
+ type: Object,
513
+ decorators: [{
514
+ type: Inject,
515
+ args: [PLATFORM_ID]
516
+ }]
517
+ }, {
518
+ type: i0.NgZone
519
+ }, {
520
+ type: undefined,
521
+ decorators: [{
522
+ type: Inject,
523
+ args: [CSP_NONCE]
524
+ }]
525
+ }, {
526
+ type: i0.ɵTracingService,
527
+ decorators: [{
528
+ type: Inject,
529
+ args: [_TracingService]
530
+ }, {
531
+ type: Optional
532
+ }]
533
+ }]
534
+ });
486
535
  class DefaultDomRenderer2 {
487
- eventManager;
488
- doc;
489
- ngZone;
490
- platformIsServer;
491
- tracingService;
492
- data = Object.create(null);
493
- /**
494
- * By default this renderer throws when encountering synthetic properties
495
- * This can be disabled for example by the AsyncAnimationRendererFactory
496
- */
497
- throwOnSyntheticProps = true;
498
- constructor(eventManager, doc, ngZone, platformIsServer, tracingService) {
499
- this.eventManager = eventManager;
500
- this.doc = doc;
501
- this.ngZone = ngZone;
502
- this.platformIsServer = platformIsServer;
503
- this.tracingService = tracingService;
504
- }
505
- destroy() { }
506
- destroyNode = null;
507
- createElement(name, namespace) {
508
- if (namespace) {
509
- // TODO: `|| namespace` was added in
510
- // https://github.com/angular/angular/commit/2b9cc8503d48173492c29f5a271b61126104fbdb to
511
- // support how Ivy passed around the namespace URI rather than short name at the time. It did
512
- // not, however extend the support to other parts of the system (setAttribute, setAttribute,
513
- // and the ServerRenderer). We should decide what exactly the semantics for dealing with
514
- // namespaces should be and make it consistent.
515
- // Related issues:
516
- // https://github.com/angular/angular/issues/44028
517
- // https://github.com/angular/angular/issues/44883
518
- return this.doc.createElementNS(NAMESPACE_URIS[namespace] || namespace, name);
519
- }
520
- return this.doc.createElement(name);
521
- }
522
- createComment(value) {
523
- return this.doc.createComment(value);
524
- }
525
- createText(value) {
526
- return this.doc.createTextNode(value);
527
- }
528
- appendChild(parent, newChild) {
529
- const targetParent = isTemplateNode(parent) ? parent.content : parent;
530
- targetParent.appendChild(newChild);
531
- }
532
- insertBefore(parent, newChild, refChild) {
533
- if (parent) {
534
- const targetParent = isTemplateNode(parent) ? parent.content : parent;
535
- targetParent.insertBefore(newChild, refChild);
536
- }
537
- }
538
- removeChild(_parent, oldChild) {
539
- // child was removed
540
- oldChild.remove();
541
- }
542
- selectRootElement(selectorOrNode, preserveContent) {
543
- let el = typeof selectorOrNode === 'string' ? this.doc.querySelector(selectorOrNode) : selectorOrNode;
544
- if (!el) {
545
- throw new _RuntimeError(-5104 /* RuntimeErrorCode.ROOT_NODE_NOT_FOUND */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
546
- `The selector "${selectorOrNode}" did not match any elements`);
547
- }
548
- if (!preserveContent) {
549
- el.textContent = '';
550
- }
551
- return el;
552
- }
553
- parentNode(node) {
554
- return node.parentNode;
555
- }
556
- nextSibling(node) {
557
- return node.nextSibling;
558
- }
559
- setAttribute(el, name, value, namespace) {
560
- if (namespace) {
561
- name = namespace + ':' + name;
562
- const namespaceUri = NAMESPACE_URIS[namespace];
563
- if (namespaceUri) {
564
- el.setAttributeNS(namespaceUri, name, value);
565
- }
566
- else {
567
- el.setAttribute(name, value);
568
- }
569
- }
570
- else {
571
- el.setAttribute(name, value);
572
- }
573
- }
574
- removeAttribute(el, name, namespace) {
575
- if (namespace) {
576
- const namespaceUri = NAMESPACE_URIS[namespace];
577
- if (namespaceUri) {
578
- el.removeAttributeNS(namespaceUri, name);
579
- }
580
- else {
581
- el.removeAttribute(`${namespace}:${name}`);
582
- }
583
- }
584
- else {
585
- el.removeAttribute(name);
586
- }
587
- }
588
- addClass(el, name) {
589
- el.classList.add(name);
590
- }
591
- removeClass(el, name) {
592
- el.classList.remove(name);
593
- }
594
- setStyle(el, style, value, flags) {
595
- if (flags & (RendererStyleFlags2.DashCase | RendererStyleFlags2.Important)) {
596
- el.style.setProperty(style, value, flags & RendererStyleFlags2.Important ? 'important' : '');
597
- }
598
- else {
599
- el.style[style] = value;
600
- }
601
- }
602
- removeStyle(el, style, flags) {
603
- if (flags & RendererStyleFlags2.DashCase) {
604
- // removeProperty has no effect when used on camelCased properties.
605
- el.style.removeProperty(style);
606
- }
607
- else {
608
- el.style[style] = '';
609
- }
610
- }
611
- setProperty(el, name, value) {
612
- if (el == null) {
613
- return;
614
- }
615
- (typeof ngDevMode === 'undefined' || ngDevMode) &&
616
- this.throwOnSyntheticProps &&
617
- checkNoSyntheticProp(name, 'property');
618
- el[name] = value;
619
- }
620
- setValue(node, value) {
621
- node.nodeValue = value;
622
- }
623
- listen(target, event, callback, options) {
624
- (typeof ngDevMode === 'undefined' || ngDevMode) &&
625
- this.throwOnSyntheticProps &&
626
- checkNoSyntheticProp(event, 'listener');
627
- if (typeof target === 'string') {
628
- target = _getDOM().getGlobalEventTarget(this.doc, target);
629
- if (!target) {
630
- throw new _RuntimeError(5102 /* RuntimeErrorCode.UNSUPPORTED_EVENT_TARGET */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
631
- `Unsupported event target ${target} for event ${event}`);
632
- }
633
- }
634
- let wrappedCallback = this.decoratePreventDefault(callback);
635
- if (this.tracingService?.wrapEventListener) {
636
- wrappedCallback = this.tracingService.wrapEventListener(target, event, wrappedCallback);
637
- }
638
- return this.eventManager.addEventListener(target, event, wrappedCallback, options);
639
- }
640
- decoratePreventDefault(eventHandler) {
641
- // `DebugNode.triggerEventHandler` needs to know if the listener was created with
642
- // decoratePreventDefault or is a listener added outside the Angular context so it can handle
643
- // the two differently. In the first case, the special '__ngUnwrap__' token is passed to the
644
- // unwrap the listener (see below).
645
- return (event) => {
646
- // Ivy uses '__ngUnwrap__' as a special token that allows us to unwrap the function
647
- // so that it can be invoked programmatically by `DebugNode.triggerEventHandler`. The
648
- // debug_node can inspect the listener toString contents for the existence of this special
649
- // token. Because the token is a string literal, it is ensured to not be modified by compiled
650
- // code.
651
- if (event === '__ngUnwrap__') {
652
- return eventHandler;
653
- }
654
- // Run the event handler inside the ngZone because event handlers are not patched
655
- // by Zone on the server. This is required only for tests.
656
- const allowDefaultBehavior = typeof ngServerMode !== 'undefined' && ngServerMode
657
- ? this.ngZone.runGuarded(() => eventHandler(event))
658
- : eventHandler(event);
659
- if (allowDefaultBehavior === false) {
660
- event.preventDefault();
661
- }
662
- return undefined;
663
- };
664
- }
536
+ eventManager;
537
+ doc;
538
+ ngZone;
539
+ platformIsServer;
540
+ tracingService;
541
+ data = Object.create(null);
542
+ throwOnSyntheticProps = true;
543
+ constructor(eventManager, doc, ngZone, platformIsServer, tracingService) {
544
+ this.eventManager = eventManager;
545
+ this.doc = doc;
546
+ this.ngZone = ngZone;
547
+ this.platformIsServer = platformIsServer;
548
+ this.tracingService = tracingService;
549
+ }
550
+ destroy() {}
551
+ destroyNode = null;
552
+ createElement(name, namespace) {
553
+ if (namespace) {
554
+ return this.doc.createElementNS(NAMESPACE_URIS[namespace] || namespace, name);
555
+ }
556
+ return this.doc.createElement(name);
557
+ }
558
+ createComment(value) {
559
+ return this.doc.createComment(value);
560
+ }
561
+ createText(value) {
562
+ return this.doc.createTextNode(value);
563
+ }
564
+ appendChild(parent, newChild) {
565
+ const targetParent = isTemplateNode(parent) ? parent.content : parent;
566
+ targetParent.appendChild(newChild);
567
+ }
568
+ insertBefore(parent, newChild, refChild) {
569
+ if (parent) {
570
+ const targetParent = isTemplateNode(parent) ? parent.content : parent;
571
+ targetParent.insertBefore(newChild, refChild);
572
+ }
573
+ }
574
+ removeChild(_parent, oldChild) {
575
+ oldChild.remove();
576
+ }
577
+ selectRootElement(selectorOrNode, preserveContent) {
578
+ let el = typeof selectorOrNode === 'string' ? this.doc.querySelector(selectorOrNode) : selectorOrNode;
579
+ if (!el) {
580
+ throw new _RuntimeError(-5104, (typeof ngDevMode === 'undefined' || ngDevMode) && `The selector "${selectorOrNode}" did not match any elements`);
581
+ }
582
+ if (!preserveContent) {
583
+ el.textContent = '';
584
+ }
585
+ return el;
586
+ }
587
+ parentNode(node) {
588
+ return node.parentNode;
589
+ }
590
+ nextSibling(node) {
591
+ return node.nextSibling;
592
+ }
593
+ setAttribute(el, name, value, namespace) {
594
+ if (namespace) {
595
+ name = namespace + ':' + name;
596
+ const namespaceUri = NAMESPACE_URIS[namespace];
597
+ if (namespaceUri) {
598
+ el.setAttributeNS(namespaceUri, name, value);
599
+ } else {
600
+ el.setAttribute(name, value);
601
+ }
602
+ } else {
603
+ el.setAttribute(name, value);
604
+ }
605
+ }
606
+ removeAttribute(el, name, namespace) {
607
+ if (namespace) {
608
+ const namespaceUri = NAMESPACE_URIS[namespace];
609
+ if (namespaceUri) {
610
+ el.removeAttributeNS(namespaceUri, name);
611
+ } else {
612
+ el.removeAttribute(`${namespace}:${name}`);
613
+ }
614
+ } else {
615
+ el.removeAttribute(name);
616
+ }
617
+ }
618
+ addClass(el, name) {
619
+ el.classList.add(name);
620
+ }
621
+ removeClass(el, name) {
622
+ el.classList.remove(name);
623
+ }
624
+ setStyle(el, style, value, flags) {
625
+ if (flags & (RendererStyleFlags2.DashCase | RendererStyleFlags2.Important)) {
626
+ el.style.setProperty(style, value, flags & RendererStyleFlags2.Important ? 'important' : '');
627
+ } else {
628
+ el.style[style] = value;
629
+ }
630
+ }
631
+ removeStyle(el, style, flags) {
632
+ if (flags & RendererStyleFlags2.DashCase) {
633
+ el.style.removeProperty(style);
634
+ } else {
635
+ el.style[style] = '';
636
+ }
637
+ }
638
+ setProperty(el, name, value) {
639
+ if (el == null) {
640
+ return;
641
+ }
642
+ (typeof ngDevMode === 'undefined' || ngDevMode) && this.throwOnSyntheticProps && checkNoSyntheticProp(name, 'property');
643
+ el[name] = value;
644
+ }
645
+ setValue(node, value) {
646
+ node.nodeValue = value;
647
+ }
648
+ listen(target, event, callback, options) {
649
+ (typeof ngDevMode === 'undefined' || ngDevMode) && this.throwOnSyntheticProps && checkNoSyntheticProp(event, 'listener');
650
+ if (typeof target === 'string') {
651
+ target = _getDOM().getGlobalEventTarget(this.doc, target);
652
+ if (!target) {
653
+ throw new _RuntimeError(5102, (typeof ngDevMode === 'undefined' || ngDevMode) && `Unsupported event target ${target} for event ${event}`);
654
+ }
655
+ }
656
+ let wrappedCallback = this.decoratePreventDefault(callback);
657
+ if (this.tracingService?.wrapEventListener) {
658
+ wrappedCallback = this.tracingService.wrapEventListener(target, event, wrappedCallback);
659
+ }
660
+ return this.eventManager.addEventListener(target, event, wrappedCallback, options);
661
+ }
662
+ decoratePreventDefault(eventHandler) {
663
+ return event => {
664
+ if (event === '__ngUnwrap__') {
665
+ return eventHandler;
666
+ }
667
+ const allowDefaultBehavior = typeof ngServerMode !== 'undefined' && ngServerMode ? this.ngZone.runGuarded(() => eventHandler(event)) : eventHandler(event);
668
+ if (allowDefaultBehavior === false) {
669
+ event.preventDefault();
670
+ }
671
+ return undefined;
672
+ };
673
+ }
665
674
  }
666
675
  const AT_CHARCODE = (() => '@'.charCodeAt(0))();
667
676
  function checkNoSyntheticProp(name, nameKind) {
668
- if (name.charCodeAt(0) === AT_CHARCODE) {
669
- throw new _RuntimeError(5105 /* RuntimeErrorCode.UNEXPECTED_SYNTHETIC_PROPERTY */, `Unexpected synthetic ${nameKind} ${name} found. Please make sure that:
677
+ if (name.charCodeAt(0) === AT_CHARCODE) {
678
+ throw new _RuntimeError(5105, `Unexpected synthetic ${nameKind} ${name} found. Please make sure that:
670
679
  - Make sure \`provideAnimationsAsync()\`, \`provideAnimations()\` or \`provideNoopAnimations()\` call was added to a list of providers used to bootstrap an application.
671
680
  - There is a corresponding animation configuration named \`${name}\` defined in the \`animations\` field of the \`@Component\` decorator (see https://angular.dev/api/core/Component#animations).`);
672
- }
681
+ }
673
682
  }
674
683
  function isTemplateNode(node) {
675
- return node.tagName === 'TEMPLATE' && node.content !== undefined;
684
+ return node.tagName === 'TEMPLATE' && node.content !== undefined;
676
685
  }
677
686
  class ShadowDomRenderer extends DefaultDomRenderer2 {
678
- hostEl;
679
- sharedStylesHost;
680
- shadowRoot;
681
- constructor(eventManager, hostEl, component, doc, ngZone, nonce, platformIsServer, tracingService, sharedStylesHost) {
682
- super(eventManager, doc, ngZone, platformIsServer, tracingService);
683
- this.hostEl = hostEl;
684
- this.sharedStylesHost = sharedStylesHost;
685
- this.shadowRoot = hostEl.attachShadow({ mode: 'open' });
686
- // SharedStylesHost is used to add styles to the shadow root by ShadowDom.
687
- // This is optional as it is not used by IsolatedShadowDom.
688
- if (this.sharedStylesHost) {
689
- this.sharedStylesHost.addHost(this.shadowRoot);
690
- }
691
- let styles = component.styles;
692
- if (ngDevMode) {
693
- // We only do this in development, as for production users should not add CSS sourcemaps to components.
694
- const baseHref = _getDOM().getBaseHref(doc) ?? '';
695
- styles = addBaseHrefToCssSourceMap(baseHref, styles);
696
- }
697
- styles = shimStylesContent(component.id, styles);
698
- for (const style of styles) {
699
- const styleEl = document.createElement('style');
700
- if (nonce) {
701
- styleEl.setAttribute('nonce', nonce);
702
- }
703
- styleEl.textContent = style;
704
- this.shadowRoot.appendChild(styleEl);
705
- }
706
- // Apply any external component styles to the shadow root for the component's element.
707
- // The ShadowDOM renderer uses an alternative execution path for component styles that
708
- // does not use the SharedStylesHost that other encapsulation modes leverage. Much like
709
- // the manual addition of embedded styles directly above, any external stylesheets
710
- // must be manually added here to ensure ShadowDOM components are correctly styled.
711
- // TODO: Consider reworking the DOM Renderers to consolidate style handling.
712
- const styleUrls = component.getExternalStyles?.();
713
- if (styleUrls) {
714
- for (const styleUrl of styleUrls) {
715
- const linkEl = createLinkElement(styleUrl, doc);
716
- if (nonce) {
717
- linkEl.setAttribute('nonce', nonce);
718
- }
719
- this.shadowRoot.appendChild(linkEl);
720
- }
721
- }
722
- }
723
- nodeOrShadowRoot(node) {
724
- return node === this.hostEl ? this.shadowRoot : node;
725
- }
726
- appendChild(parent, newChild) {
727
- return super.appendChild(this.nodeOrShadowRoot(parent), newChild);
728
- }
729
- insertBefore(parent, newChild, refChild) {
730
- return super.insertBefore(this.nodeOrShadowRoot(parent), newChild, refChild);
731
- }
732
- removeChild(_parent, oldChild) {
733
- return super.removeChild(null, oldChild);
734
- }
735
- parentNode(node) {
736
- return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(node)));
737
- }
738
- destroy() {
739
- if (this.sharedStylesHost) {
740
- this.sharedStylesHost.removeHost(this.shadowRoot);
741
- }
742
- }
687
+ hostEl;
688
+ sharedStylesHost;
689
+ shadowRoot;
690
+ constructor(eventManager, hostEl, component, doc, ngZone, nonce, platformIsServer, tracingService, sharedStylesHost) {
691
+ super(eventManager, doc, ngZone, platformIsServer, tracingService);
692
+ this.hostEl = hostEl;
693
+ this.sharedStylesHost = sharedStylesHost;
694
+ this.shadowRoot = hostEl.attachShadow({
695
+ mode: 'open'
696
+ });
697
+ if (this.sharedStylesHost) {
698
+ this.sharedStylesHost.addHost(this.shadowRoot);
699
+ }
700
+ let styles = component.styles;
701
+ if (ngDevMode) {
702
+ const baseHref = _getDOM().getBaseHref(doc) ?? '';
703
+ styles = addBaseHrefToCssSourceMap(baseHref, styles);
704
+ }
705
+ styles = shimStylesContent(component.id, styles);
706
+ for (const style of styles) {
707
+ const styleEl = document.createElement('style');
708
+ if (nonce) {
709
+ styleEl.setAttribute('nonce', nonce);
710
+ }
711
+ styleEl.textContent = style;
712
+ this.shadowRoot.appendChild(styleEl);
713
+ }
714
+ const styleUrls = component.getExternalStyles?.();
715
+ if (styleUrls) {
716
+ for (const styleUrl of styleUrls) {
717
+ const linkEl = createLinkElement(styleUrl, doc);
718
+ if (nonce) {
719
+ linkEl.setAttribute('nonce', nonce);
720
+ }
721
+ this.shadowRoot.appendChild(linkEl);
722
+ }
723
+ }
724
+ }
725
+ nodeOrShadowRoot(node) {
726
+ return node === this.hostEl ? this.shadowRoot : node;
727
+ }
728
+ appendChild(parent, newChild) {
729
+ return super.appendChild(this.nodeOrShadowRoot(parent), newChild);
730
+ }
731
+ insertBefore(parent, newChild, refChild) {
732
+ return super.insertBefore(this.nodeOrShadowRoot(parent), newChild, refChild);
733
+ }
734
+ removeChild(_parent, oldChild) {
735
+ return super.removeChild(null, oldChild);
736
+ }
737
+ parentNode(node) {
738
+ return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(node)));
739
+ }
740
+ destroy() {
741
+ if (this.sharedStylesHost) {
742
+ this.sharedStylesHost.removeHost(this.shadowRoot);
743
+ }
744
+ }
743
745
  }
744
746
  class NoneEncapsulationDomRenderer extends DefaultDomRenderer2 {
745
- sharedStylesHost;
746
- removeStylesOnCompDestroy;
747
- styles;
748
- styleUrls;
749
- constructor(eventManager, sharedStylesHost, component, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService, compId) {
750
- super(eventManager, doc, ngZone, platformIsServer, tracingService);
751
- this.sharedStylesHost = sharedStylesHost;
752
- this.removeStylesOnCompDestroy = removeStylesOnCompDestroy;
753
- let styles = component.styles;
754
- if (ngDevMode) {
755
- // We only do this in development, as for production users should not add CSS sourcemaps to components.
756
- const baseHref = _getDOM().getBaseHref(doc) ?? '';
757
- styles = addBaseHrefToCssSourceMap(baseHref, styles);
758
- }
759
- this.styles = compId ? shimStylesContent(compId, styles) : styles;
760
- this.styleUrls = component.getExternalStyles?.(compId);
761
- }
762
- applyStyles() {
763
- this.sharedStylesHost.addStyles(this.styles, this.styleUrls);
764
- }
765
- destroy() {
766
- if (!this.removeStylesOnCompDestroy) {
767
- return;
768
- }
769
- if (_allLeavingAnimations.size === 0) {
770
- this.sharedStylesHost.removeStyles(this.styles, this.styleUrls);
771
- }
772
- }
747
+ sharedStylesHost;
748
+ removeStylesOnCompDestroy;
749
+ styles;
750
+ styleUrls;
751
+ constructor(eventManager, sharedStylesHost, component, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService, compId) {
752
+ super(eventManager, doc, ngZone, platformIsServer, tracingService);
753
+ this.sharedStylesHost = sharedStylesHost;
754
+ this.removeStylesOnCompDestroy = removeStylesOnCompDestroy;
755
+ let styles = component.styles;
756
+ if (ngDevMode) {
757
+ const baseHref = _getDOM().getBaseHref(doc) ?? '';
758
+ styles = addBaseHrefToCssSourceMap(baseHref, styles);
759
+ }
760
+ this.styles = compId ? shimStylesContent(compId, styles) : styles;
761
+ this.styleUrls = component.getExternalStyles?.(compId);
762
+ }
763
+ applyStyles() {
764
+ this.sharedStylesHost.addStyles(this.styles, this.styleUrls);
765
+ }
766
+ destroy() {
767
+ if (!this.removeStylesOnCompDestroy) {
768
+ return;
769
+ }
770
+ if (_allLeavingAnimations.size === 0) {
771
+ this.sharedStylesHost.removeStyles(this.styles, this.styleUrls);
772
+ }
773
+ }
773
774
  }
774
775
  class EmulatedEncapsulationDomRenderer2 extends NoneEncapsulationDomRenderer {
775
- contentAttr;
776
- hostAttr;
777
- constructor(eventManager, sharedStylesHost, component, appId, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService) {
778
- const compId = appId + '-' + component.id;
779
- super(eventManager, sharedStylesHost, component, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService, compId);
780
- this.contentAttr = shimContentAttribute(compId);
781
- this.hostAttr = shimHostAttribute(compId);
782
- }
783
- applyToHost(element) {
784
- this.applyStyles();
785
- this.setAttribute(element, this.hostAttr, '');
786
- }
787
- createElement(parent, name) {
788
- const el = super.createElement(parent, name);
789
- super.setAttribute(el, this.contentAttr, '');
790
- return el;
791
- }
776
+ contentAttr;
777
+ hostAttr;
778
+ constructor(eventManager, sharedStylesHost, component, appId, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService) {
779
+ const compId = appId + '-' + component.id;
780
+ super(eventManager, sharedStylesHost, component, removeStylesOnCompDestroy, doc, ngZone, platformIsServer, tracingService, compId);
781
+ this.contentAttr = shimContentAttribute(compId);
782
+ this.hostAttr = shimHostAttribute(compId);
783
+ }
784
+ applyToHost(element) {
785
+ this.applyStyles();
786
+ this.setAttribute(element, this.hostAttr, '');
787
+ }
788
+ createElement(parent, name) {
789
+ const el = super.createElement(parent, name);
790
+ super.setAttribute(el, this.contentAttr, '');
791
+ return el;
792
+ }
792
793
  }
793
794
 
794
- export { DomRendererFactory2, EVENT_MANAGER_PLUGINS, EventManager, EventManagerPlugin, REMOVE_STYLES_ON_COMPONENT_DESTROY, SharedStylesHost };
795
+ export { DomEventsPlugin, DomRendererFactory2, EVENT_MANAGER_PLUGINS, EventManager, EventManagerPlugin, REMOVE_STYLES_ON_COMPONENT_DESTROY, SharedStylesHost };
795
796
  //# sourceMappingURL=_dom_renderer-chunk.mjs.map