src/replace.js
function replaceElement(element, attrs = {}) {
  const elementAttrs = getAttrs(element);
  const name = elementAttrs['data-feather'];
  delete elementAttrs['data-feather'];

  const svgString = icons[name].toSvg({
    ...attrs,
    ...elementAttrs,
    ...{ class: classnames(attrs.class, elementAttrs.class) },
  });
  const svgDocument = new DOMParser().parseFromString(
    svgString,
    'image/svg+xml',
  );
  const svgElement = svgDocument.querySelector('svg');

  element.parentNode.replaceChild(svgElement, element);
}
function replaceElement(element, attrs = {}) {
  const elementAttrs = getAttrs(element);
  const name = elementAttrs['data-feather'];
  delete elementAttrs['data-feather'];

  const svgString = icons[name].toSvg({
    ...attrs,
    ...elementAttrs,
    ...{ class: classnames(attrs.class, elementAttrs.class) },
  });
  const svgDocument = new DOMParser().parseFromString(
    svgString,
    'image/svg+xml',
  );
  const svgElement = svgDocument.querySelector('svg');

  element.parentNode.replaceChild(svgElement, element);
}
function replaceElement ( element , attrs = { } ) { const elementAttrs = getAttrs ( element ) ; const name = elementAttrs [ 'data-feather' ] ; delete elementAttrs [ 'data-feather' ] ; const svgString = icons [ name ] . toSvg ( { ... attrs , ... elementAttrs , ... { class : classnames ( attrs . class , elementAttrs . class ) } , } ) ; const svgDocument = new DOMParser ( ) . parseFromString ( svgString , 'image/svg+xml' , ) ; const svgElement = svgDocument . querySelector ( 'svg' ) ; element . parentNode . replaceChild ( svgElement , element ) ; }
Replace a single HTML element with SVG markup
corresponding to the element's `data-feather` attribute value.
@param {HTMLElement} element
@param {Object} attrs
Replace a single HTML element with SVG markup corresponding to the element s data - feather attribute value .