[BUG] init creates 0 property in jQuery prototype
At two places in the init function, jQuery writes to the zero property
this[0] = selector;
this[0] = elem;
At this point, jQuery may not have a zero property, which I think
makes this slot now accessible in all jQuery objects?
Anyways, if the jQuery object is filtered down to having a length of
zero, it will still have a zero property, and new jQuery objects can
end up with this property.
The reason why this bug does not often show up is that the length is
set correctly, and there is rarely a practical reason to access the
first element. But if one tries to retrieve the zero object with
get(0), the previous value will show instead of undefined.
The only way I know how to fix this is to replace the offending lines
with
return jQuery([selector]);
return jQuery([elem]);