From: Alexander Ebert Date: Fri, 12 Jul 2013 12:20:16 +0000 (+0200) Subject: Added proper support for objects passed to $.fn.data() X-Git-Tag: 2.0.0_Beta_5~70^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1f4f33dd7a31388dee829f0ee4cb4d8bead53acd;p=GitHub%2FWoltLab%2FWCF.git Added proper support for objects passed to $.fn.data() Fixes #1407 --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index cfba8c6a77..93020c1e6a 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -19,10 +19,31 @@ * @see jQuery.fn.data() */ jQuery.fn.data = function(key, value) { - if (key && key.match(/ID$/)) { - arguments[0] = key.replace(/ID$/, '-id'); + if (key) { + switch (typeof key) { + case 'object': + for (var $key in key) { + if ($key.match(/ID$/)) { + var $value = key[$key]; + delete key[$key]; + + $key = $key.replace(/ID$/, '-id'); + key[$key] = $value; + } + } + + arguments[0] = key; + break; + + case 'string': + if (key.match(/ID$/)) { + arguments[0] = key.replace(/ID$/, '-id'); + } + break; + } } + // call jQuery's own data method var $data = $jQueryData.apply(this, arguments);