Skip to content

Instantly share code, notes, and snippets.

@blubbll
Created March 20, 2019 05:59
Show Gist options
  • Save blubbll/6444df76be83b15e40c60aec2f56c05c to your computer and use it in GitHub Desktop.
Save blubbll/6444df76be83b15e40c60aec2f56c05c to your computer and use it in GitHub Desktop.
domparser polyfill
//domparser polyfill
!function (t) { "use strict"; var e = t.prototype, r = e.parseFromString; try { if ((new t).parseFromString("", "text/html")) return; } catch (t) { console.error(t); } e.parseFromString = function (t, e) { if (/^\s*text\/html\s*(?:;|$3)/i.test(e)) { var n = document.implementation.createHTMLDocument(""); return t.toLowerCase().indexOf("<!doctype") > -1 ? n.documentElement.innerHTML = t : n.body.innerHTML = t, n; } return r.apply(this, arguments); }; }(DOMParser);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment