jQuery data() may change elements that were not in the selector?
<p>It seems jQuery data can link data to multiple elements. In the example below, both elements get both properties, although it would appear that it should only affect the <code>#one</code> element.</p>

<p>I assume this is expected behavior in jQuery, since it's changing an object?</p>

<pre><code>&lt;div id="one" class="thing"&gt;&lt;/div&gt;
&lt;div id="two" class="thing"&gt;&lt;/div&gt;
&lt;div id="three" class="thing"&gt;&lt;/div&gt;
&lt;script&gt;
jQuery(function($) {
    $('.thing').data('obj',{a:'a'});

    $('#one').data('obj',$.extend($('#one').data('obj'),{one:'one'}));

    //Display:
    for (i in $('#one').data('obj')) {
        alert(i+' in obj.');
    }
    for (i in $('#two').data('obj')) {
        alert(i+' in obj.');
    }
})
&lt;/script&gt;
</code></pre>

<p>JSFiddle:</p>

<p><a href="http://jsfiddle.net/qFZ6y/" rel="nofollow">http://jsfiddle.net/qFZ6y/</a></p>

<p>I know initializing with .each() function to set individual datas solves this problem, but would this be considered a bug in javascript or jQuery??</p>
