Bug Tracker

Ticket #2402: string_lambda_for_grep_and_map.patch

File string_lambda_for_grep_and_map.patch, 888 bytes (added by markusb, 14 years ago)

I copied the string-lambda feature back from the previous release. I don't know why it has been removed.

  • javascripts/jquery.js

     
    11791179        },
    11801180
    11811181        grep: function( elems, callback, inv ) {
     1182                // If a string is passed in for the function, make a function
     1183                // for it (a handy shortcut)
     1184                if ( typeof callback == "string" )
     1185                        callback = eval("false||function(a,i){return " + callback + "}");
     1186
    11821187                var ret = [];
    11831188
    11841189                // Go through the array, only saving the items
     
    11911196        },
    11921197
    11931198        map: function( elems, callback ) {
     1199                // If a string is passed in for the function, make a function
     1200                // for it (a handy shortcut)
     1201                if ( typeof callback == "string" )
     1202                        callback = eval("false||function(a,i){return " + callback + "}");
     1203
    11941204                var ret = [];
    11951205
    11961206                // Go through the array, translating each of the items to their