Skip to main content

Bug Tracker

Side navigation

#9767 closed feature (wontfix)

Opened July 07, 2011 07:16AM UTC

Closed July 07, 2011 01:39PM UTC

Last modified July 07, 2011 02:01PM UTC

It would be nice to have Ruby-like shortcuts for map()

Reported by: gurdiga@gmail.com Owned by:
Priority: low Milestone: 1.next
Component: core Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

It would be nice to have Ruby-like shortcuts for map(), so that one would be able to say:

$('table td.amount').map('innerHTML');

instead of

$('table td.amount').map(function() {
  return this.innerHTML;
});

or

$('#cardwall .tickets').map('getAttribute', 'data-hours');

instead of

$('#cardwall .tickets').map(function() {
  return this.getAttribute(data-hours);
});

or

$('.post .body').map('$excerpt', 100);

instead of

$('.post .body').map(function() {
  return $(this).excerpt(100);
});
Attachments (0)
Change History (3)

Changed July 07, 2011 01:39PM UTC by timmywil comment:1

component: unfiledcore
priority: undecidedlow
resolution: → wontfix
status: newclosed

I see the advantage, but I don't think it belongs in jQuery. jQuery has its own style and consistency to its API and something like this would open up a new world of APIs that would only bloat the code.

Changed July 07, 2011 01:56PM UTC by ajpiano comment:2

+1 to Timmy - It's nice, but a little too sugary for core.

Changed July 07, 2011 02:01PM UTC by rwaldron comment:3

+1 to timmywill and ajpiano

You should definitely turn this into a "duck punch plugin", Paul Irish has written an excellent article on the subject:

http://paulirish.com/2010/duck-punching-with-jquery/

Keep the jQuery team posted if the plugin gains traction and wide use