1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { DOCUMENT } from '@angular/common';
|
---|
9 | import { HttpClient } from '@angular/common/http';
|
---|
10 | import { ErrorHandler, Inject, Injectable, Optional, SecurityContext, SkipSelf, } from '@angular/core';
|
---|
11 | import { DomSanitizer } from '@angular/platform-browser';
|
---|
12 | import { forkJoin, of as observableOf, throwError as observableThrow } from 'rxjs';
|
---|
13 | import { catchError, finalize, map, share, tap } from 'rxjs/operators';
|
---|
14 | import * as i0 from "@angular/core";
|
---|
15 | import * as i1 from "@angular/common/http";
|
---|
16 | import * as i2 from "@angular/platform-browser";
|
---|
17 | import * as i3 from "@angular/common";
|
---|
18 | /**
|
---|
19 | * Returns an exception to be thrown in the case when attempting to
|
---|
20 | * load an icon with a name that cannot be found.
|
---|
21 | * @docs-private
|
---|
22 | */
|
---|
23 | export function getMatIconNameNotFoundError(iconName) {
|
---|
24 | return Error(`Unable to find icon with the name "${iconName}"`);
|
---|
25 | }
|
---|
26 | /**
|
---|
27 | * Returns an exception to be thrown when the consumer attempts to use
|
---|
28 | * `<mat-icon>` without including @angular/common/http.
|
---|
29 | * @docs-private
|
---|
30 | */
|
---|
31 | export function getMatIconNoHttpProviderError() {
|
---|
32 | return Error('Could not find HttpClient provider for use with Angular Material icons. ' +
|
---|
33 | 'Please include the HttpClientModule from @angular/common/http in your ' +
|
---|
34 | 'app imports.');
|
---|
35 | }
|
---|
36 | /**
|
---|
37 | * Returns an exception to be thrown when a URL couldn't be sanitized.
|
---|
38 | * @param url URL that was attempted to be sanitized.
|
---|
39 | * @docs-private
|
---|
40 | */
|
---|
41 | export function getMatIconFailedToSanitizeUrlError(url) {
|
---|
42 | return Error(`The URL provided to MatIconRegistry was not trusted as a resource URL ` +
|
---|
43 | `via Angular's DomSanitizer. Attempted URL was "${url}".`);
|
---|
44 | }
|
---|
45 | /**
|
---|
46 | * Returns an exception to be thrown when a HTML string couldn't be sanitized.
|
---|
47 | * @param literal HTML that was attempted to be sanitized.
|
---|
48 | * @docs-private
|
---|
49 | */
|
---|
50 | export function getMatIconFailedToSanitizeLiteralError(literal) {
|
---|
51 | return Error(`The literal provided to MatIconRegistry was not trusted as safe HTML by ` +
|
---|
52 | `Angular's DomSanitizer. Attempted literal was "${literal}".`);
|
---|
53 | }
|
---|
54 | /**
|
---|
55 | * Configuration for an icon, including the URL and possibly the cached SVG element.
|
---|
56 | * @docs-private
|
---|
57 | */
|
---|
58 | class SvgIconConfig {
|
---|
59 | constructor(url, svgText, options) {
|
---|
60 | this.url = url;
|
---|
61 | this.svgText = svgText;
|
---|
62 | this.options = options;
|
---|
63 | }
|
---|
64 | }
|
---|
65 | /**
|
---|
66 | * Service to register and display icons used by the `<mat-icon>` component.
|
---|
67 | * - Registers icon URLs by namespace and name.
|
---|
68 | * - Registers icon set URLs by namespace.
|
---|
69 | * - Registers aliases for CSS classes, for use with icon fonts.
|
---|
70 | * - Loads icons from URLs and extracts individual icons from icon sets.
|
---|
71 | */
|
---|
72 | export class MatIconRegistry {
|
---|
73 | constructor(_httpClient, _sanitizer, document, _errorHandler) {
|
---|
74 | this._httpClient = _httpClient;
|
---|
75 | this._sanitizer = _sanitizer;
|
---|
76 | this._errorHandler = _errorHandler;
|
---|
77 | /**
|
---|
78 | * URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]".
|
---|
79 | */
|
---|
80 | this._svgIconConfigs = new Map();
|
---|
81 | /**
|
---|
82 | * SvgIconConfig objects and cached SVG elements for icon sets, keyed by namespace.
|
---|
83 | * Multiple icon sets can be registered under the same namespace.
|
---|
84 | */
|
---|
85 | this._iconSetConfigs = new Map();
|
---|
86 | /** Cache for icons loaded by direct URLs. */
|
---|
87 | this._cachedIconsByUrl = new Map();
|
---|
88 | /** In-progress icon fetches. Used to coalesce multiple requests to the same URL. */
|
---|
89 | this._inProgressUrlFetches = new Map();
|
---|
90 | /** Map from font identifiers to their CSS class names. Used for icon fonts. */
|
---|
91 | this._fontCssClassesByAlias = new Map();
|
---|
92 | /** Registered icon resolver functions. */
|
---|
93 | this._resolvers = [];
|
---|
94 | /**
|
---|
95 | * The CSS class to apply when an `<mat-icon>` component has no icon name, url, or font specified.
|
---|
96 | * The default 'material-icons' value assumes that the material icon font has been loaded as
|
---|
97 | * described at http://google.github.io/material-design-icons/#icon-font-for-the-web
|
---|
98 | */
|
---|
99 | this._defaultFontSetClass = 'material-icons';
|
---|
100 | this._document = document;
|
---|
101 | }
|
---|
102 | /**
|
---|
103 | * Registers an icon by URL in the default namespace.
|
---|
104 | * @param iconName Name under which the icon should be registered.
|
---|
105 | * @param url
|
---|
106 | */
|
---|
107 | addSvgIcon(iconName, url, options) {
|
---|
108 | return this.addSvgIconInNamespace('', iconName, url, options);
|
---|
109 | }
|
---|
110 | /**
|
---|
111 | * Registers an icon using an HTML string in the default namespace.
|
---|
112 | * @param iconName Name under which the icon should be registered.
|
---|
113 | * @param literal SVG source of the icon.
|
---|
114 | */
|
---|
115 | addSvgIconLiteral(iconName, literal, options) {
|
---|
116 | return this.addSvgIconLiteralInNamespace('', iconName, literal, options);
|
---|
117 | }
|
---|
118 | /**
|
---|
119 | * Registers an icon by URL in the specified namespace.
|
---|
120 | * @param namespace Namespace in which the icon should be registered.
|
---|
121 | * @param iconName Name under which the icon should be registered.
|
---|
122 | * @param url
|
---|
123 | */
|
---|
124 | addSvgIconInNamespace(namespace, iconName, url, options) {
|
---|
125 | return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig(url, null, options));
|
---|
126 | }
|
---|
127 | /**
|
---|
128 | * Registers an icon resolver function with the registry. The function will be invoked with the
|
---|
129 | * name and namespace of an icon when the registry tries to resolve the URL from which to fetch
|
---|
130 | * the icon. The resolver is expected to return a `SafeResourceUrl` that points to the icon,
|
---|
131 | * an object with the icon URL and icon options, or `null` if the icon is not supported. Resolvers
|
---|
132 | * will be invoked in the order in which they have been registered.
|
---|
133 | * @param resolver Resolver function to be registered.
|
---|
134 | */
|
---|
135 | addSvgIconResolver(resolver) {
|
---|
136 | this._resolvers.push(resolver);
|
---|
137 | return this;
|
---|
138 | }
|
---|
139 | /**
|
---|
140 | * Registers an icon using an HTML string in the specified namespace.
|
---|
141 | * @param namespace Namespace in which the icon should be registered.
|
---|
142 | * @param iconName Name under which the icon should be registered.
|
---|
143 | * @param literal SVG source of the icon.
|
---|
144 | */
|
---|
145 | addSvgIconLiteralInNamespace(namespace, iconName, literal, options) {
|
---|
146 | const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
|
---|
147 | // TODO: add an ngDevMode check
|
---|
148 | if (!cleanLiteral) {
|
---|
149 | throw getMatIconFailedToSanitizeLiteralError(literal);
|
---|
150 | }
|
---|
151 | return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig('', cleanLiteral, options));
|
---|
152 | }
|
---|
153 | /**
|
---|
154 | * Registers an icon set by URL in the default namespace.
|
---|
155 | * @param url
|
---|
156 | */
|
---|
157 | addSvgIconSet(url, options) {
|
---|
158 | return this.addSvgIconSetInNamespace('', url, options);
|
---|
159 | }
|
---|
160 | /**
|
---|
161 | * Registers an icon set using an HTML string in the default namespace.
|
---|
162 | * @param literal SVG source of the icon set.
|
---|
163 | */
|
---|
164 | addSvgIconSetLiteral(literal, options) {
|
---|
165 | return this.addSvgIconSetLiteralInNamespace('', literal, options);
|
---|
166 | }
|
---|
167 | /**
|
---|
168 | * Registers an icon set by URL in the specified namespace.
|
---|
169 | * @param namespace Namespace in which to register the icon set.
|
---|
170 | * @param url
|
---|
171 | */
|
---|
172 | addSvgIconSetInNamespace(namespace, url, options) {
|
---|
173 | return this._addSvgIconSetConfig(namespace, new SvgIconConfig(url, null, options));
|
---|
174 | }
|
---|
175 | /**
|
---|
176 | * Registers an icon set using an HTML string in the specified namespace.
|
---|
177 | * @param namespace Namespace in which to register the icon set.
|
---|
178 | * @param literal SVG source of the icon set.
|
---|
179 | */
|
---|
180 | addSvgIconSetLiteralInNamespace(namespace, literal, options) {
|
---|
181 | const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
|
---|
182 | if (!cleanLiteral) {
|
---|
183 | throw getMatIconFailedToSanitizeLiteralError(literal);
|
---|
184 | }
|
---|
185 | return this._addSvgIconSetConfig(namespace, new SvgIconConfig('', cleanLiteral, options));
|
---|
186 | }
|
---|
187 | /**
|
---|
188 | * Defines an alias for a CSS class name to be used for icon fonts. Creating an matIcon
|
---|
189 | * component with the alias as the fontSet input will cause the class name to be applied
|
---|
190 | * to the `<mat-icon>` element.
|
---|
191 | *
|
---|
192 | * @param alias Alias for the font.
|
---|
193 | * @param className Class name override to be used instead of the alias.
|
---|
194 | */
|
---|
195 | registerFontClassAlias(alias, className = alias) {
|
---|
196 | this._fontCssClassesByAlias.set(alias, className);
|
---|
197 | return this;
|
---|
198 | }
|
---|
199 | /**
|
---|
200 | * Returns the CSS class name associated with the alias by a previous call to
|
---|
201 | * registerFontClassAlias. If no CSS class has been associated, returns the alias unmodified.
|
---|
202 | */
|
---|
203 | classNameForFontAlias(alias) {
|
---|
204 | return this._fontCssClassesByAlias.get(alias) || alias;
|
---|
205 | }
|
---|
206 | /**
|
---|
207 | * Sets the CSS class name to be used for icon fonts when an `<mat-icon>` component does not
|
---|
208 | * have a fontSet input value, and is not loading an icon by name or URL.
|
---|
209 | *
|
---|
210 | * @param className
|
---|
211 | */
|
---|
212 | setDefaultFontSetClass(className) {
|
---|
213 | this._defaultFontSetClass = className;
|
---|
214 | return this;
|
---|
215 | }
|
---|
216 | /**
|
---|
217 | * Returns the CSS class name to be used for icon fonts when an `<mat-icon>` component does not
|
---|
218 | * have a fontSet input value, and is not loading an icon by name or URL.
|
---|
219 | */
|
---|
220 | getDefaultFontSetClass() {
|
---|
221 | return this._defaultFontSetClass;
|
---|
222 | }
|
---|
223 | /**
|
---|
224 | * Returns an Observable that produces the icon (as an `<svg>` DOM element) from the given URL.
|
---|
225 | * The response from the URL may be cached so this will not always cause an HTTP request, but
|
---|
226 | * the produced element will always be a new copy of the originally fetched icon. (That is,
|
---|
227 | * it will not contain any modifications made to elements previously returned).
|
---|
228 | *
|
---|
229 | * @param safeUrl URL from which to fetch the SVG icon.
|
---|
230 | */
|
---|
231 | getSvgIconFromUrl(safeUrl) {
|
---|
232 | const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
|
---|
233 | if (!url) {
|
---|
234 | throw getMatIconFailedToSanitizeUrlError(safeUrl);
|
---|
235 | }
|
---|
236 | const cachedIcon = this._cachedIconsByUrl.get(url);
|
---|
237 | if (cachedIcon) {
|
---|
238 | return observableOf(cloneSvg(cachedIcon));
|
---|
239 | }
|
---|
240 | return this._loadSvgIconFromConfig(new SvgIconConfig(safeUrl, null)).pipe(tap(svg => this._cachedIconsByUrl.set(url, svg)), map(svg => cloneSvg(svg)));
|
---|
241 | }
|
---|
242 | /**
|
---|
243 | * Returns an Observable that produces the icon (as an `<svg>` DOM element) with the given name
|
---|
244 | * and namespace. The icon must have been previously registered with addIcon or addIconSet;
|
---|
245 | * if not, the Observable will throw an error.
|
---|
246 | *
|
---|
247 | * @param name Name of the icon to be retrieved.
|
---|
248 | * @param namespace Namespace in which to look for the icon.
|
---|
249 | */
|
---|
250 | getNamedSvgIcon(name, namespace = '') {
|
---|
251 | const key = iconKey(namespace, name);
|
---|
252 | let config = this._svgIconConfigs.get(key);
|
---|
253 | // Return (copy of) cached icon if possible.
|
---|
254 | if (config) {
|
---|
255 | return this._getSvgFromConfig(config);
|
---|
256 | }
|
---|
257 | // Otherwise try to resolve the config from one of the resolver functions.
|
---|
258 | config = this._getIconConfigFromResolvers(namespace, name);
|
---|
259 | if (config) {
|
---|
260 | this._svgIconConfigs.set(key, config);
|
---|
261 | return this._getSvgFromConfig(config);
|
---|
262 | }
|
---|
263 | // See if we have any icon sets registered for the namespace.
|
---|
264 | const iconSetConfigs = this._iconSetConfigs.get(namespace);
|
---|
265 | if (iconSetConfigs) {
|
---|
266 | return this._getSvgFromIconSetConfigs(name, iconSetConfigs);
|
---|
267 | }
|
---|
268 | return observableThrow(getMatIconNameNotFoundError(key));
|
---|
269 | }
|
---|
270 | ngOnDestroy() {
|
---|
271 | this._resolvers = [];
|
---|
272 | this._svgIconConfigs.clear();
|
---|
273 | this._iconSetConfigs.clear();
|
---|
274 | this._cachedIconsByUrl.clear();
|
---|
275 | }
|
---|
276 | /**
|
---|
277 | * Returns the cached icon for a SvgIconConfig if available, or fetches it from its URL if not.
|
---|
278 | */
|
---|
279 | _getSvgFromConfig(config) {
|
---|
280 | if (config.svgText) {
|
---|
281 | // We already have the SVG element for this icon, return a copy.
|
---|
282 | return observableOf(cloneSvg(this._svgElementFromConfig(config)));
|
---|
283 | }
|
---|
284 | else {
|
---|
285 | // Fetch the icon from the config's URL, cache it, and return a copy.
|
---|
286 | return this._loadSvgIconFromConfig(config).pipe(map(svg => cloneSvg(svg)));
|
---|
287 | }
|
---|
288 | }
|
---|
289 | /**
|
---|
290 | * Attempts to find an icon with the specified name in any of the SVG icon sets.
|
---|
291 | * First searches the available cached icons for a nested element with a matching name, and
|
---|
292 | * if found copies the element to a new `<svg>` element. If not found, fetches all icon sets
|
---|
293 | * that have not been cached, and searches again after all fetches are completed.
|
---|
294 | * The returned Observable produces the SVG element if possible, and throws
|
---|
295 | * an error if no icon with the specified name can be found.
|
---|
296 | */
|
---|
297 | _getSvgFromIconSetConfigs(name, iconSetConfigs) {
|
---|
298 | // For all the icon set SVG elements we've fetched, see if any contain an icon with the
|
---|
299 | // requested name.
|
---|
300 | const namedIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
|
---|
301 | if (namedIcon) {
|
---|
302 | // We could cache namedIcon in _svgIconConfigs, but since we have to make a copy every
|
---|
303 | // time anyway, there's probably not much advantage compared to just always extracting
|
---|
304 | // it from the icon set.
|
---|
305 | return observableOf(namedIcon);
|
---|
306 | }
|
---|
307 | // Not found in any cached icon sets. If there are icon sets with URLs that we haven't
|
---|
308 | // fetched, fetch them now and look for iconName in the results.
|
---|
309 | const iconSetFetchRequests = iconSetConfigs
|
---|
310 | .filter(iconSetConfig => !iconSetConfig.svgText)
|
---|
311 | .map(iconSetConfig => {
|
---|
312 | return this._loadSvgIconSetFromConfig(iconSetConfig).pipe(catchError((err) => {
|
---|
313 | const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
|
---|
314 | // Swallow errors fetching individual URLs so the
|
---|
315 | // combined Observable won't necessarily fail.
|
---|
316 | const errorMessage = `Loading icon set URL: ${url} failed: ${err.message}`;
|
---|
317 | this._errorHandler.handleError(new Error(errorMessage));
|
---|
318 | return observableOf(null);
|
---|
319 | }));
|
---|
320 | });
|
---|
321 | // Fetch all the icon set URLs. When the requests complete, every IconSet should have a
|
---|
322 | // cached SVG element (unless the request failed), and we can check again for the icon.
|
---|
323 | return forkJoin(iconSetFetchRequests).pipe(map(() => {
|
---|
324 | const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
|
---|
325 | // TODO: add an ngDevMode check
|
---|
326 | if (!foundIcon) {
|
---|
327 | throw getMatIconNameNotFoundError(name);
|
---|
328 | }
|
---|
329 | return foundIcon;
|
---|
330 | }));
|
---|
331 | }
|
---|
332 | /**
|
---|
333 | * Searches the cached SVG elements for the given icon sets for a nested icon element whose "id"
|
---|
334 | * tag matches the specified name. If found, copies the nested element to a new SVG element and
|
---|
335 | * returns it. Returns null if no matching element is found.
|
---|
336 | */
|
---|
337 | _extractIconWithNameFromAnySet(iconName, iconSetConfigs) {
|
---|
338 | // Iterate backwards, so icon sets added later have precedence.
|
---|
339 | for (let i = iconSetConfigs.length - 1; i >= 0; i--) {
|
---|
340 | const config = iconSetConfigs[i];
|
---|
341 | // Parsing the icon set's text into an SVG element can be expensive. We can avoid some of
|
---|
342 | // the parsing by doing a quick check using `indexOf` to see if there's any chance for the
|
---|
343 | // icon to be in the set. This won't be 100% accurate, but it should help us avoid at least
|
---|
344 | // some of the parsing.
|
---|
345 | if (config.svgText && config.svgText.indexOf(iconName) > -1) {
|
---|
346 | const svg = this._svgElementFromConfig(config);
|
---|
347 | const foundIcon = this._extractSvgIconFromSet(svg, iconName, config.options);
|
---|
348 | if (foundIcon) {
|
---|
349 | return foundIcon;
|
---|
350 | }
|
---|
351 | }
|
---|
352 | }
|
---|
353 | return null;
|
---|
354 | }
|
---|
355 | /**
|
---|
356 | * Loads the content of the icon URL specified in the SvgIconConfig and creates an SVG element
|
---|
357 | * from it.
|
---|
358 | */
|
---|
359 | _loadSvgIconFromConfig(config) {
|
---|
360 | return this._fetchIcon(config).pipe(tap(svgText => config.svgText = svgText), map(() => this._svgElementFromConfig(config)));
|
---|
361 | }
|
---|
362 | /**
|
---|
363 | * Loads the content of the icon set URL specified in the
|
---|
364 | * SvgIconConfig and attaches it to the config.
|
---|
365 | */
|
---|
366 | _loadSvgIconSetFromConfig(config) {
|
---|
367 | if (config.svgText) {
|
---|
368 | return observableOf(null);
|
---|
369 | }
|
---|
370 | return this._fetchIcon(config).pipe(tap(svgText => config.svgText = svgText));
|
---|
371 | }
|
---|
372 | /**
|
---|
373 | * Searches the cached element of the given SvgIconConfig for a nested icon element whose "id"
|
---|
374 | * tag matches the specified name. If found, copies the nested element to a new SVG element and
|
---|
375 | * returns it. Returns null if no matching element is found.
|
---|
376 | */
|
---|
377 | _extractSvgIconFromSet(iconSet, iconName, options) {
|
---|
378 | // Use the `id="iconName"` syntax in order to escape special
|
---|
379 | // characters in the ID (versus using the #iconName syntax).
|
---|
380 | const iconSource = iconSet.querySelector(`[id="${iconName}"]`);
|
---|
381 | if (!iconSource) {
|
---|
382 | return null;
|
---|
383 | }
|
---|
384 | // Clone the element and remove the ID to prevent multiple elements from being added
|
---|
385 | // to the page with the same ID.
|
---|
386 | const iconElement = iconSource.cloneNode(true);
|
---|
387 | iconElement.removeAttribute('id');
|
---|
388 | // If the icon node is itself an <svg> node, clone and return it directly. If not, set it as
|
---|
389 | // the content of a new <svg> node.
|
---|
390 | if (iconElement.nodeName.toLowerCase() === 'svg') {
|
---|
391 | return this._setSvgAttributes(iconElement, options);
|
---|
392 | }
|
---|
393 | // If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>. Note
|
---|
394 | // that the same could be achieved by referring to it via <use href="#id">, however the <use>
|
---|
395 | // tag is problematic on Firefox, because it needs to include the current page path.
|
---|
396 | if (iconElement.nodeName.toLowerCase() === 'symbol') {
|
---|
397 | return this._setSvgAttributes(this._toSvgElement(iconElement), options);
|
---|
398 | }
|
---|
399 | // createElement('SVG') doesn't work as expected; the DOM ends up with
|
---|
400 | // the correct nodes, but the SVG content doesn't render. Instead we
|
---|
401 | // have to create an empty SVG node using innerHTML and append its content.
|
---|
402 | // Elements created using DOMParser.parseFromString have the same problem.
|
---|
403 | // http://stackoverflow.com/questions/23003278/svg-innerhtml-in-firefox-can-not-display
|
---|
404 | const svg = this._svgElementFromString('<svg></svg>');
|
---|
405 | // Clone the node so we don't remove it from the parent icon set element.
|
---|
406 | svg.appendChild(iconElement);
|
---|
407 | return this._setSvgAttributes(svg, options);
|
---|
408 | }
|
---|
409 | /**
|
---|
410 | * Creates a DOM element from the given SVG string.
|
---|
411 | */
|
---|
412 | _svgElementFromString(str) {
|
---|
413 | const div = this._document.createElement('DIV');
|
---|
414 | div.innerHTML = str;
|
---|
415 | const svg = div.querySelector('svg');
|
---|
416 | // TODO: add an ngDevMode check
|
---|
417 | if (!svg) {
|
---|
418 | throw Error('<svg> tag not found');
|
---|
419 | }
|
---|
420 | return svg;
|
---|
421 | }
|
---|
422 | /**
|
---|
423 | * Converts an element into an SVG node by cloning all of its children.
|
---|
424 | */
|
---|
425 | _toSvgElement(element) {
|
---|
426 | const svg = this._svgElementFromString('<svg></svg>');
|
---|
427 | const attributes = element.attributes;
|
---|
428 | // Copy over all the attributes from the `symbol` to the new SVG, except the id.
|
---|
429 | for (let i = 0; i < attributes.length; i++) {
|
---|
430 | const { name, value } = attributes[i];
|
---|
431 | if (name !== 'id') {
|
---|
432 | svg.setAttribute(name, value);
|
---|
433 | }
|
---|
434 | }
|
---|
435 | for (let i = 0; i < element.childNodes.length; i++) {
|
---|
436 | if (element.childNodes[i].nodeType === this._document.ELEMENT_NODE) {
|
---|
437 | svg.appendChild(element.childNodes[i].cloneNode(true));
|
---|
438 | }
|
---|
439 | }
|
---|
440 | return svg;
|
---|
441 | }
|
---|
442 | /**
|
---|
443 | * Sets the default attributes for an SVG element to be used as an icon.
|
---|
444 | */
|
---|
445 | _setSvgAttributes(svg, options) {
|
---|
446 | svg.setAttribute('fit', '');
|
---|
447 | svg.setAttribute('height', '100%');
|
---|
448 | svg.setAttribute('width', '100%');
|
---|
449 | svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
|
---|
450 | svg.setAttribute('focusable', 'false'); // Disable IE11 default behavior to make SVGs focusable.
|
---|
451 | if (options && options.viewBox) {
|
---|
452 | svg.setAttribute('viewBox', options.viewBox);
|
---|
453 | }
|
---|
454 | return svg;
|
---|
455 | }
|
---|
456 | /**
|
---|
457 | * Returns an Observable which produces the string contents of the given icon. Results may be
|
---|
458 | * cached, so future calls with the same URL may not cause another HTTP request.
|
---|
459 | */
|
---|
460 | _fetchIcon(iconConfig) {
|
---|
461 | var _a;
|
---|
462 | const { url: safeUrl, options } = iconConfig;
|
---|
463 | const withCredentials = (_a = options === null || options === void 0 ? void 0 : options.withCredentials) !== null && _a !== void 0 ? _a : false;
|
---|
464 | if (!this._httpClient) {
|
---|
465 | throw getMatIconNoHttpProviderError();
|
---|
466 | }
|
---|
467 | // TODO: add an ngDevMode check
|
---|
468 | if (safeUrl == null) {
|
---|
469 | throw Error(`Cannot fetch icon from URL "${safeUrl}".`);
|
---|
470 | }
|
---|
471 | const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
|
---|
472 | // TODO: add an ngDevMode check
|
---|
473 | if (!url) {
|
---|
474 | throw getMatIconFailedToSanitizeUrlError(safeUrl);
|
---|
475 | }
|
---|
476 | // Store in-progress fetches to avoid sending a duplicate request for a URL when there is
|
---|
477 | // already a request in progress for that URL. It's necessary to call share() on the
|
---|
478 | // Observable returned by http.get() so that multiple subscribers don't cause multiple XHRs.
|
---|
479 | const inProgressFetch = this._inProgressUrlFetches.get(url);
|
---|
480 | if (inProgressFetch) {
|
---|
481 | return inProgressFetch;
|
---|
482 | }
|
---|
483 | const req = this._httpClient.get(url, { responseType: 'text', withCredentials }).pipe(finalize(() => this._inProgressUrlFetches.delete(url)), share());
|
---|
484 | this._inProgressUrlFetches.set(url, req);
|
---|
485 | return req;
|
---|
486 | }
|
---|
487 | /**
|
---|
488 | * Registers an icon config by name in the specified namespace.
|
---|
489 | * @param namespace Namespace in which to register the icon config.
|
---|
490 | * @param iconName Name under which to register the config.
|
---|
491 | * @param config Config to be registered.
|
---|
492 | */
|
---|
493 | _addSvgIconConfig(namespace, iconName, config) {
|
---|
494 | this._svgIconConfigs.set(iconKey(namespace, iconName), config);
|
---|
495 | return this;
|
---|
496 | }
|
---|
497 | /**
|
---|
498 | * Registers an icon set config in the specified namespace.
|
---|
499 | * @param namespace Namespace in which to register the icon config.
|
---|
500 | * @param config Config to be registered.
|
---|
501 | */
|
---|
502 | _addSvgIconSetConfig(namespace, config) {
|
---|
503 | const configNamespace = this._iconSetConfigs.get(namespace);
|
---|
504 | if (configNamespace) {
|
---|
505 | configNamespace.push(config);
|
---|
506 | }
|
---|
507 | else {
|
---|
508 | this._iconSetConfigs.set(namespace, [config]);
|
---|
509 | }
|
---|
510 | return this;
|
---|
511 | }
|
---|
512 | /** Parses a config's text into an SVG element. */
|
---|
513 | _svgElementFromConfig(config) {
|
---|
514 | if (!config.svgElement) {
|
---|
515 | const svg = this._svgElementFromString(config.svgText);
|
---|
516 | this._setSvgAttributes(svg, config.options);
|
---|
517 | config.svgElement = svg;
|
---|
518 | }
|
---|
519 | return config.svgElement;
|
---|
520 | }
|
---|
521 | /** Tries to create an icon config through the registered resolver functions. */
|
---|
522 | _getIconConfigFromResolvers(namespace, name) {
|
---|
523 | for (let i = 0; i < this._resolvers.length; i++) {
|
---|
524 | const result = this._resolvers[i](name, namespace);
|
---|
525 | if (result) {
|
---|
526 | return isSafeUrlWithOptions(result) ?
|
---|
527 | new SvgIconConfig(result.url, null, result.options) :
|
---|
528 | new SvgIconConfig(result, null);
|
---|
529 | }
|
---|
530 | }
|
---|
531 | return undefined;
|
---|
532 | }
|
---|
533 | }
|
---|
534 | MatIconRegistry.ɵprov = i0.ɵɵdefineInjectable({ factory: function MatIconRegistry_Factory() { return new MatIconRegistry(i0.ɵɵinject(i1.HttpClient, 8), i0.ɵɵinject(i2.DomSanitizer), i0.ɵɵinject(i3.DOCUMENT, 8), i0.ɵɵinject(i0.ErrorHandler)); }, token: MatIconRegistry, providedIn: "root" });
|
---|
535 | MatIconRegistry.decorators = [
|
---|
536 | { type: Injectable, args: [{ providedIn: 'root' },] }
|
---|
537 | ];
|
---|
538 | MatIconRegistry.ctorParameters = () => [
|
---|
539 | { type: HttpClient, decorators: [{ type: Optional }] },
|
---|
540 | { type: DomSanitizer },
|
---|
541 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
|
---|
542 | { type: ErrorHandler }
|
---|
543 | ];
|
---|
544 | /** @docs-private */
|
---|
545 | export function ICON_REGISTRY_PROVIDER_FACTORY(parentRegistry, httpClient, sanitizer, errorHandler, document) {
|
---|
546 | return parentRegistry || new MatIconRegistry(httpClient, sanitizer, document, errorHandler);
|
---|
547 | }
|
---|
548 | /** @docs-private */
|
---|
549 | export const ICON_REGISTRY_PROVIDER = {
|
---|
550 | // If there is already an MatIconRegistry available, use that. Otherwise, provide a new one.
|
---|
551 | provide: MatIconRegistry,
|
---|
552 | deps: [
|
---|
553 | [new Optional(), new SkipSelf(), MatIconRegistry],
|
---|
554 | [new Optional(), HttpClient],
|
---|
555 | DomSanitizer,
|
---|
556 | ErrorHandler,
|
---|
557 | [new Optional(), DOCUMENT],
|
---|
558 | ],
|
---|
559 | useFactory: ICON_REGISTRY_PROVIDER_FACTORY,
|
---|
560 | };
|
---|
561 | /** Clones an SVGElement while preserving type information. */
|
---|
562 | function cloneSvg(svg) {
|
---|
563 | return svg.cloneNode(true);
|
---|
564 | }
|
---|
565 | /** Returns the cache key to use for an icon namespace and name. */
|
---|
566 | function iconKey(namespace, name) {
|
---|
567 | return namespace + ':' + name;
|
---|
568 | }
|
---|
569 | function isSafeUrlWithOptions(value) {
|
---|
570 | return !!(value.url && value.options);
|
---|
571 | }
|
---|
572 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWNvbi1yZWdpc3RyeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9pY29uL2ljb24tcmVnaXN0cnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLFFBQVEsRUFBQyxNQUFNLGlCQUFpQixDQUFDO0FBQ3pDLE9BQU8sRUFBQyxVQUFVLEVBQW9CLE1BQU0sc0JBQXNCLENBQUM7QUFDbkUsT0FBTyxFQUNMLFlBQVksRUFDWixNQUFNLEVBQ04sVUFBVSxFQUVWLFFBQVEsRUFDUixlQUFlLEVBQ2YsUUFBUSxHQUVULE1BQU0sZUFBZSxDQUFDO0FBQ3ZCLE9BQU8sRUFBQyxZQUFZLEVBQTRCLE1BQU0sMkJBQTJCLENBQUM7QUFDbEYsT0FBTyxFQUFDLFFBQVEsRUFBYyxFQUFFLElBQUksWUFBWSxFQUFFLFVBQVUsSUFBSSxlQUFlLEVBQUMsTUFBTSxNQUFNLENBQUM7QUFDN0YsT0FBTyxFQUFDLFVBQVUsRUFBRSxRQUFRLEVBQUUsR0FBRyxFQUFFLEtBQUssRUFBRSxHQUFHLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQ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