MCPcopy Create free account
hub / github.com/angular/components / _cacheChildrenWithExternalReferences

Method _cacheChildrenWithExternalReferences

src/material/icon/icon.ts:419–442  ·  view source on GitHub ↗

* Caches the children of an SVG element that have `url()` * references that we need to prefix with the current path.

(element: SVGElement)

Source from the content-addressed store, hash-verified

417 * references that we need to prefix with the current path.
418 */
419 private _cacheChildrenWithExternalReferences(element: SVGElement) {
420 const elementsWithFuncIri = element.querySelectorAll(funcIriAttributeSelector);
421 const elements = (this._elementsWithExternalReferences =
422 this._elementsWithExternalReferences || new Map());
423
424 for (let i = 0; i < elementsWithFuncIri.length; i++) {
425 funcIriAttributes.forEach(attr => {
426 const elementWithReference = elementsWithFuncIri[i];
427 const value = elementWithReference.getAttribute(attr);
428 const match = value ? value.match(funcIriPattern) : null;
429
430 if (match) {
431 let attributes = elements.get(elementWithReference);
432
433 if (!attributes) {
434 attributes = [];
435 elements.set(elementWithReference, attributes);
436 }
437
438 attributes!.push({name: attr, value: match[1]});
439 }
440 });
441 }
442 }
443
444 /** Sets a new SVG icon with a particular name. */
445 private _updateSvgIcon(rawName: string | undefined) {

Callers 1

_setSvgElementMethod · 0.95

Calls 4

setMethod · 0.80
getAttributeMethod · 0.65
getMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected