#996 enhancement
Diego Perini

enhancements to $$ to accept context

Reported by Diego Perini | February 25th, 2010 @ 12:32 AM

Could this help enable us to pass a context parameter to $$() and still be backward compatible ?

window.$$ = function $$() {
  var context, args = $A(arguments);
  if (typeof args[args.length - 1] != 'string') {
    context = args.pop();
  return Prototype.Selector.select(args.join(', '), context);

Should work with the engine of choice since all accepts a context parameter.

-- Diego

Comments and changes to this ticket

  • Tobie Langel

    Tobie Langel February 25th, 2010 @ 12:57 PM

    • Tag cleared.

    What's wrong with:

  • Diego Perini

    Diego Perini February 25th, 2010 @ 08:11 PM

    • Tag set to selectors

    I was comparing the current 1.6.1 definition of $$():

    window.$$ = function() {
      var expression = $A(arguments).join(', ');
      return Prototype.Selector.select(expression, document);

    and I see that the "document" context is a static reference to the loading context there, so IFRAMES are not handled.

    Your example will work too if the expression is not split over multiple strings arguments as $$() is prepared to handle.

    The enhancement is about being able to use the "current" $$() passing a context parameter as last without breaking older code.

  • Tobie Langel

    Tobie Langel February 25th, 2010 @ 09:37 PM

    • State changed from “new” to “enhancement”
    • Tag cleared.
  • Tobie Langel

    Tobie Langel March 1st, 2010 @ 01:24 AM

    • Tag set to section:dom

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins