DomQuery icon indicating copy to clipboard operation
DomQuery copied to clipboard

Return wrong html

Open kartofelek007 opened this issue 2 years ago • 1 comments

I have html with script inline:

<script>
{
    const btn = document.querySelector("#test3");
    btn.addEventListener("click", e => {
        document.querySelector("#test3div").innerHTML = `
            <div class="module">
                <h2>lorem ipsum</h2>
                <p>lorem <strong>lorem </strong></p>
                <button class="button">klik</button>
            </div>
        `;
    });
}
</script>

I use your class:

function generateContentTable($content) {
 $dom = new DomQuery($content);
return $dom->find('html')->html();
}

where $content is all html. This generate wrong html:

<script>
{
    const btn = document.querySelector("#test3");
    btn.addEventListener("click", e => {
        document.querySelector("#test3div").innerHTML = `
            <div class="module">
                <h2>lorem ipsum
                <p>lorem <strong>lorem </strong>
                <button class="button">klik
            </script>
</div>
        `;
    });
}

kartofelek007 avatar Dec 05 '21 09:12 kartofelek007

After while i find this: https://stackoverflow.com/questions/24575136/domdocument-removes-html-tags-in-javascript-string#answer-66474146

kartofelek007 avatar Dec 05 '21 10:12 kartofelek007