mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Fixes #13548. .data should not miss attr() set data-* with hyphenated property names
This commit is contained in:
parent
9f981c84a5
commit
3212a29369
@ -264,6 +264,14 @@ jQuery.fn.extend({
|
|||||||
if ( data !== undefined ) {
|
if ( data !== undefined ) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to get data from the cache
|
||||||
|
// with the key camelized
|
||||||
|
data = data_user.get( elem, camelKey );
|
||||||
|
if ( data !== undefined ) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
// Attempt to "discover" the data in
|
// Attempt to "discover" the data in
|
||||||
// HTML5 custom data-* attrs
|
// HTML5 custom data-* attrs
|
||||||
data = dataAttr( elem, key, undefined );
|
data = dataAttr( elem, key, undefined );
|
||||||
|
@ -497,7 +497,7 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
|
|||||||
div.remove();
|
div.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("jQuery.data should not miss data with preset hyphenated property names", function() {
|
test(".data should not miss preset data-* w/ hyphenated property names", function() {
|
||||||
|
|
||||||
expect(2);
|
expect(2);
|
||||||
|
|
||||||
@ -514,6 +514,17 @@ test("jQuery.data should not miss data with preset hyphenated property names", f
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(".data should not miss attr() set data-* with hyphenated property names", function() {
|
||||||
|
expect(1);
|
||||||
|
|
||||||
|
var div = jQuery("<div/>").appendTo("#qunit-fixture");
|
||||||
|
|
||||||
|
div.attr( "data-long-param", "test" );
|
||||||
|
div.data( "long-param", { a: 2 });
|
||||||
|
|
||||||
|
deepEqual( div.data("long-param"), { a: 2 }, "data with property long-param was found" );
|
||||||
|
});
|
||||||
|
|
||||||
test("jQuery.data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() {
|
test("jQuery.data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() {
|
||||||
|
|
||||||
var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
|
var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
|
||||||
|
Loading…
Reference in New Issue
Block a user