title: Conditionally adding tags options parameter to select2
body: <p>I have multiple elements on a page that are triggering a load of select2 to the element. I'm trying to conditionally check if the element has a certain class, and if so add the <code>tag</code> option; otherwise do not. I thought something like this would work, but it's not:</p>
  <pre><code>$('.element_to_add_select_two_on').select2({
      tags:function(element) {
          return (element.className === 'classname_i_am_targeting');
      },
  });
  </code></pre>
  <p>What am I missing here? I'm subjecting myself to the following buffoonery to get this to target and load:</p>
  <pre><code>$('.element_to_add_select_two_on').each((index,element) =&gt; {
      let showTags = false;
  
      if ($(element).attr('class').split(' ').includes('classname_i_am_targeting')) {
          showTags = true;
      }
  
      $(element).select2({
          tags:showTags,
      });
  });
  </code></pre>