Created
February 10, 2009 13:59
-
-
Save yoko/61394 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
(function($) { | |
$.override = function(target, copy) { | |
$.each(copy, function f(k, v) { | |
if (v === null) | |
delete target[k]; | |
else if (typeof v == 'object') { | |
target[k] = target[k] || ($.isArray(v) ? [] : {}); | |
var _target = target; | |
var _copy = copy; | |
target = target[k]; | |
copy = copy[k]; | |
$.each(v, f); | |
target = _target; | |
copy = _copy; | |
} | |
else | |
target[k] = v; | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment