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

Method _clearSvgElement

src/material/icon/icon.ts:340–359  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

338 }
339
340 private _clearSvgElement() {
341 const layoutElement: HTMLElement = this._elementRef.nativeElement;
342 let childCount = layoutElement.childNodes.length;
343
344 if (this._elementsWithExternalReferences) {
345 this._elementsWithExternalReferences.clear();
346 }
347
348 // Remove existing non-element child nodes and SVGs, and add the new SVG element. Note that
349 // we can't use innerHTML, because IE will throw if the element has a data binding.
350 while (childCount--) {
351 const child = layoutElement.childNodes[childCount];
352
353 // 1 corresponds to Node.ELEMENT_NODE. We remove all non-element nodes in order to get rid
354 // of any loose text nodes, as well as any SVG elements in order to remove any old icons.
355 if (child.nodeType !== 1 || child.nodeName.toLowerCase() === 'svg') {
356 child.remove();
357 }
358 }
359 }
360
361 private _updateFontIconClasses() {
362 if (!this._usingFontIcon()) {

Callers 2

svgIconMethod · 0.95
_setSvgElementMethod · 0.95

Calls 2

clearMethod · 0.65
removeMethod · 0.65

Tested by

no test coverage detected