Bug in jQuery DOM element builder for Images with width/height?
<p>The <a href="http://api.jquery.com/jQuery/#jQuery2" rel="nofollow">jQuery 1.4 docs</a> describe how jQuery can be used to create DOM elements on the fly from a provided HTML string and set of attributes.  For example:</p>

<pre><code>var d = $('&lt;div/&gt;', {id:'foo', className:'bar'});
d; // =&gt; [&lt;div id="foo" class="bar"&gt;&lt;/div&gt;]
d.attr('id'); // =&gt; "foo"
d.attr('class'); // =&gt; "bar"
</code></pre>

<p>This is great; however, there appears to be a bug when using this shortcut for images with width and height.  Instead of setting the attributes (as implied by the <a href="http://api.jquery.com/attr" rel="nofollow">attr() function</a>) it sets the CSS style:</p>

<pre><code>var x = $('&lt;img/&gt;', {width:10, height:20});
x; // =&gt; [&lt;img style=​"width:​ 10px;​ height:​ 20px;​ "&gt;​]!!!
x.attr('width'); // =&gt; 0!!!
x.attr('height'); // =&gt; 0!!!
</code></pre>

<p>This is even more confusing since jQuery behaves as expected when given a new image from the constructor:</p>

<pre><code>var y = $(new Image(10, 20));
y; // =&gt; [&lt;img width=​"10" height=​"20"&gt;]
y.attr('width'); // =&gt; 10
y.attr('height'); // =&gt; 20
</code></pre>

<p>Is this just a bug in jQuery 1.4.2 or expected behavior for some reason?</p>
