Landing pull request 403. Check for both camelized and hyphenated data property names; Fixes #9301.
More Details: - https://github.com/jquery/jquery/pull/403 - http://bugs.jquery.com/ticket/9301
This commit is contained in:
parent
c3c001cf5b
commit
0742056645
|
@ -108,7 +108,10 @@ jQuery.extend({
|
|||
return thisCache[ internalKey ] && thisCache[ internalKey ].events;
|
||||
}
|
||||
|
||||
return getByName ? thisCache[ jQuery.camelCase( name ) ] : thisCache;
|
||||
return getByName ?
|
||||
// Check for both converted-to-camel and non-converted data property names
|
||||
thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ] :
|
||||
thisCache;
|
||||
},
|
||||
|
||||
removeData: function( elem, name, pvt /* Internal Use Only */ ) {
|
||||
|
|
|
@ -508,3 +508,20 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
|
|||
|
||||
div.remove();
|
||||
});
|
||||
|
||||
test("jQuery.data should not miss data with preset hyphenated property names", function() {
|
||||
|
||||
expect(2);
|
||||
|
||||
var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
|
||||
test = {
|
||||
"camelBar": "camelBar",
|
||||
"hyphen-foo": "hyphen-foo"
|
||||
};
|
||||
|
||||
div.data( test );
|
||||
|
||||
jQuery.each( test , function(i, k) {
|
||||
equal( div.data(k), k, "data with property '"+k+"' was correctly found");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue