Would like each method when passed an object instead of a function to merge the passed object onto the DOM element.
example:
jQuery("#somediv").each({innerHTML: "blah blah blah"});
This would give a shortcut to manipulating non-attribute fields of DOM objects (such as references to other DOM objects which have been attached).
I have modified jQuery-1.2.1.js each as follows to accomplish this:
// args is for internal usage only
each: function( obj, fn, args ) {
if ( args ) {
if ( obj.length == undefined )
for ( var i in obj )
fn.apply( obj[i], args );
else
for ( var i = 0, ol = obj.length; i < ol; i++ )
if ( fn.apply( obj[i], args ) === false ) break;
// A special, fast, case for the most common use of each
} else {
if ( obj.length == undefined )
// modified to extend each to do an extend on the object returned with object passed
for ( var i in obj ) {
if (typeof fn == 'function')
fn.call( obj[i], i, obj[i] );
else if (typeof fn == 'object')
for (var f in fn)
obj[i][f]=fn[f];
}
else
if (typeof fn == 'function')
for ( var i = 0, ol = obj.length, val = obj[0];
i < ol && fn.call(val,i,val) !== false; val = obj[++i] ){}
else if (typeof fn == 'object')
for ( var i = 0, ol = obj.length; i < ol; i++)
for (var f in fn)
obj[i][f]=fn[f];
}
return obj;
},