Ticket: http://dev.jquery.com/ticket/5434
On Oct 30, 3:33 pm, John Resig <jere...@gmail.com> wrote: > This seems reasonable, as well. Can you file a ticket? Thanks. > > --John > > On Fri, Oct 30, 2009 at 2:06 AM, Robert Katić <robert.ka...@gmail.com> wrote: > > Sorry, I posted an old version of code. Here the new one: > > > jQuery.fn.add = function( selector, context ) { > > return this.pushStack( jQuery.unique( jQuery.merge( > > this.get(), > > typeof selector === "string" ? > > jQuery( selector, context > > || this.context && (this.context.ownerDocument || > > this.context) > > || this[0] && (this[0].ownerDocument || this[0]) ) : > > jQuery.makeArray( selector ) > > ))); > > }; > > > On Oct 30, 6:55 am, Robert Katić <robert.ka...@gmail.com> wrote: > >> Using $.fn.add(selector) the context property remains the same. > >> It's ok, but the given selector will be applied always with the > >> default context (document). > > >> This is not correct for me if we are using jQuery with xml documents > >> for example. > > >> $("user", xmlDoc).add("lusers"); > > >> There is no way to add lusers of the xmlDoc document! > > >> Here an optional context argument would be useful: > > >> $("user", xmlDoc).add("lusers", xmlDoc); > > >> But even this is not ideal for me. If the context argument is not > >> given (first example), which document would be used? > >> I suppose the obvious answer is xmlDoc. > > >> An corrected implementation of add() would be something like this: > > >> jQuery.fn.add = function( selector ) { > >> return this.pushStack( jQuery.unique( jQuery.merge( > >> this.get(), > >> typeof selector === "string" ? > >> jQuery( selector, (this.context || this[0] || > >> 0).ownerDocument ) : > >> jQuery.makeArray( selector ) > >> ))); > > >> }; > > > -- > > > You received this message because you are subscribed to the Google Groups > > "jQuery Development" group. > > To post to this group, send email to jquery-...@googlegroups.com. > > To unsubscribe from this group, send email to > > jquery-dev+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/jquery-dev?hl=en. -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@googlegroups.com. To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.