Is this right? A jQuery bug that erases the data store?
<p>Fire up your firebug console and try this out.</p>

<p>Compare this:</p>

<pre><code>$('body').data('x',1);
$(thisx).remove();
console.log($('body').data('x'));
</code></pre>

<p>to this: </p>

<pre><code>$('body').data('x',1);
$(this.x).remove();
console.log($('body').data('x'));
</code></pre>

<p>Notice the difference? If <code>thisx</code> is undefined, it will immediatly throw a reference error. If <code>x</code> is an undefined property of <code>this</code>, jQuery will return the document as it's result set instead. Next jQuery will attempt to remove your document (which it can't), but before doing that it will remove all data attached to any child element of the document. <strong>Thus, wiping out your data store.</strong></p>

<p>Note: <code>this</code> can be any element reference or object. You only need to have jQuery attempt to access an undefined property.</p>

<p><em>(Talk about a pain. It fails silently, and I'm trying to figure out why my data is suddenly missing. I track it down to a special case where an element reference was undefined in a specific situation.)</em></p>

<p>So on to my questions:</p>

<p>1) <strong>Before I submit a bug report</strong>, am I analyzing this correctly? Also if someone happens to know that this is a known issue, let me know. I couldn't find it in the bug tracker, but the interface isn't that great (or maybe I have this wrong).</p>

<p>2) Why is there ultimately any difference? I'm guessing <code>thisx</code> is evaluated immediately which causes the exception while <code>this.x</code> is a reference that is passed and evaluated in the called function, right? (where I think the line <code>selector = selector || document</code>; is the culprit.</p>

<p>3) <strong>Suggestions for how to handle this?</strong> I guess I should be checking that <strong>any/every</strong> element reference or property of an object (e.g. stored selector strings) is defined before I pass it to jQuery when removing something.</p>
