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

Method _cacheChildrenWithExternalReferences

src/material/icon/icon.ts:425–448  ·  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

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