X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fcore.js;h=efc654fb409444addbdc760824f90a2c878eb9a4;hb=b0c7df65d0f92b77752e8f9b33898d0e3b2c05e8;hp=f36edefa3469c4c33cd618075dc88d23dbe4666d;hpb=77da94552e94925e990d058ed81419d0835747ce;p=jquery.git diff --git a/src/core.js b/src/core.js index f36edef..efc654f 100644 --- a/src/core.js +++ b/src/core.js @@ -479,15 +479,20 @@ jQuery.fn = jQuery.prototype = { }, data: function( key, value ){ + var parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + if ( value == null ) { - if ( this.length ) { - var data = jQuery.data( this[0], key ); - return data == null ? - jQuery.data( this[0], key.split(".")[0] ) : - data; - } + var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + if ( data == undefined && this.length ) + data = jQuery.data( this[0], key ); + + return data == null && parts[1] ? + this.data( parts[0] ) : + data; } else - return this.trigger("set-" + key + "!", [value]).each(function(){ + return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ jQuery.data( this, key, value ); }); },