feathericons / feather

Simply beautiful open-source icons
https://feathericons.com
MIT License
24.65k stars 1.21k forks source link

Make replaceElement function part of the public API #1129

Open emirdaponte opened 2 years ago

emirdaponte commented 2 years ago

I think it would be nice to have more granular control of which icons to replace.

e.g. Replace the icons in two sections of the HTML with different settings.

<section id='first'>
 ...
</section>
<section id='first'>
 ...
</section>

<script>
  const firstSection = document.querySelector('#first')
  const secondSection = document.querySelector('#second')

  for (let element of firstSection.querySelectorAll('[data-feather]')) {
    feather.replaceElement(element, { class: 'foo bar', 'stroke-width': 1 })
  }

  for (let element of secondSection.querySelectorAll('[data-feather]')) {
    feather.replaceElement(element)
  }
</script>