Created
October 5, 2009 08:25
-
-
Save padolsey/201983 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Make getters return full set if first arg === true */ | |
$.each( | |
[ | |
'html', 'val', 'text', 'width', 'height', 'scrollTop', | |
'scrollLeft', 'hasClass', 'css', 'attr', 'offset', | |
'position', 'outerHeight', 'outerWidth' | |
], | |
function(){ | |
var _method = $.fn[this]; | |
if (!_method) { | |
return true; | |
} | |
$.fn[this] = function() { | |
var args = Array.prototype.slice.call(arguments); | |
if (args.shift() === true) { | |
return this.map(function(){ | |
return _method.apply($(this), args); | |
}); | |
} | |
return _method.apply(this, arguments); | |
}; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment