I have the following response returned from a server. It's a html fragment. I want to parse it with DOMParser like this:
let responseText = '<div>Text Content</div><tr><td>Cell</td></tr>';
let doc = new DOMParser().parseFromString(`<body><template>${responseText}</template></body>`, 'text/html');
let fragment = doc.body.firstChild.content;
Here the fragment
variable in runtime contains the following DOM:
#document-fragment
<div>Text Content</div>
Cell
My question: I expected it to contain <tr>
but it doesn't. How do I change the parsing code so that it properly contains element?
I'm not allowed to change response text.