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

Method _clearSvgElement

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

Source from the content-addressed store, hash-verified

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