jquery.format icon indicating copy to clipboard operation
jquery.format copied to clipboard

<img> tag without a closing slash causes incorrect indentation on subsequent tags

Open sshongru opened this issue 12 years ago • 0 comments

Steps to reproduce:

$.format("<div><div><img ></div></div>")

Actual Output:

<div>
    <div>
        <img >
        </div>
    </div>

Expected Output:

<div>
    <div>
        <img >
    </div>
</div>

Workaround:

I was able to naively workaround this by doing a replace on the string before passing it to format():

var input = "<div><div><img ></div></div>";
$.format(input.replace( /<img\s*([^>]*)>/g, "<img $1 />" ))

But this is fragile and doesn't address other tags that might also not have a closing slash.

sshongru avatar Dec 11 '13 05:12 sshongru