Search code examples
javascriptinternet-explorerpolyfills

Polyfill for Internet explorer


I'm using Tagify in my project and its working in chrome. Now I want it to work in IE9 too. So I added the polyfill that the plugin provided but it keep show error in the tagify.min.js for this line:

parseHTML:function(t){return(new DOMParser).parseFromString(t.trim(),"text/html").body.firstElementChild}

I'd be grateful for any pointers. Below is the code:

<script type="text/javascript" src="js/tagify/tagify.min.js"></script>
<script type="text/javascript" src="js/tagify/tagify.polyfills.min.js"></script>
...
<input style="width: 200px;" name="txtFormPickup"/> 
...
var inputElm = document.querySelector('input[name=txtFormPickup]');
var tagify = new Tagify(inputElm, {});
tagify.addTags([{value:"banana", color:"yellow"}, {value:"apple", color:"red"}, {value:"watermelon", color:"green"}]);


Solution

  • I have tested the sample code and it looks like it can only work with the IE 10 and IE 11 version.

    code:

    <!doctype html>
    <html>
       <head>
          <script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.min.js"></script>
          <script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.polyfills.min.js"></script>
          <link href="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.css" rel="stylesheet" type="text/css" />
       </head>
       <body>
          <input style="width: 200px;" name="txtFormPickup"/> 
          <script>
             var inputElm = document.querySelector('input[name=txtFormPickup]');
             var tagify = new Tagify(inputElm, {});
             tagify.addTags([{value:"banana", color:"yellow"}, {value:"apple", color:"red"}, {value:"watermelon", color:"green"}]);
          </script>
       </body>
    </html>

    Output in the IE 11 with different document modes:

    enter image description here

    In the documentation of Tagify, they did not clearly mention that with which version of the IE their polyfill can work. So I suggest you move to IE 11 browser that may help to fix the issue.

    IE 9 is a too old version and out of support scope of the Microsoft.