Fix for #806
[jquery.git] / src / jquery / jquery.js
index 9dcccb9..f756b67 100644 (file)
@@ -38,14 +38,14 @@ var jQuery = function(a,c) {
        
        // Handle HTML strings
        if ( typeof a  == "string" ) {
+               // HANDLE: $(html) -> $(array)
                var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
-
-               a = m ?
-                       // HANDLE: $(html) -> $(array)
-                       jQuery.clean( [ m[1] ] ) :
+               if ( m )
+                       a = jQuery.clean( [ m[1] ] );
                
-                       // HANDLE: $(expr)
-                       jQuery.find( a, c );
+               // HANDLE: $(expr)
+               else
+                       return new jQuery( c ).find( a );
        }
        
        return this.setArray(
@@ -985,7 +985,7 @@ jQuery.fn = jQuery.prototype = {
        add: function(t) {
                return this.pushStack( jQuery.merge(
                        this.get(),
-                       typeof t == "string" ? jQuery(t).get() : t )
+                       typeof t == "string" ? jQuery(t).get() : t.length ? t : [t] )
                );
        },