I'd like to parse a string and make DOM tree out of it. I decided to use documentFragment
API and I did this so far:
var htmlString ="Some really really complicated html string that only can be parsed by a real browser!";
var fragment = document.createDocumentFragment('div');
var tempDiv = document.createElement('div');
fragment.appendChild(tempDiv);
tempDiv.innerHTML = htmlString;
console.log(tempDiv);
But the problem is that this script causes my browser (Chrome specifically) to send actual HTTP requests! what do I mean? take this as example:
var htmlString ='<img src="somewhere/odd/on/the/internet" alt="alt?" />';
var fragment = document.createDocumentFragment('div');
var tempDiv = document.createElement('div');
fragment.appendChild(tempDiv);
tempDiv.innerHTML = htmlString;
console.log(tempDiv);
Which leads to:
Is there any workarounds for this? or any other better idea to parse HTML-String?