Using query to set HTML of an element to:
<div data-mine="/>">content</div>
Results in an extra closing tag inserted into the attribute
<div data-mine="></div>">content</div>
From read ing any specifications I can find, there is no encoding issue here. Why does jQuery behave this way, when setting the content using native DOM functions work fine.
Here is a snippet that demonstrates the difference between jQuery and native.
$('#native')[0].innerHTML = "<div data-h='/>'>native</div>"
$('#jquery').html("<div data-h='/>'>jquery</div>")
$('#sourceraw').text($('#source').html())
$('#nativeraw').text($('#native').html())
$('#jqueryraw').text($('#jquery').html())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h2>Elements</h2>
<p>HTML set with <code>data-</code> value of <code>"/>"</code></p>
<div id="source"><div data-h='/>'>source</div></div>
<div id="native"></div>
<div id="jquery"></div>
<h2>Resulting Inner HTML</h2>
<h3>native</h3>
<pre id="nativeraw"></pre>
<h3>source</h3>
<pre id="sourceraw"></pre>
<h3>jquery</h3>
<pre id="jqueryraw"></pre>