mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Landing pull request 461. Adds a due diligence check for pre-defined data-* attrs during removal. Fixes #10026.
More Details: - https://github.com/jquery/jquery/pull/461 - http://bugs.jquery.com/ticket/10026
This commit is contained in:
parent
1a738cb72f
commit
6805fc2cd2
@ -167,6 +167,11 @@ jQuery.extend({
|
||||
|
||||
delete thisCache[ name ];
|
||||
|
||||
// Check the actual element for predefined data-* attrs, #10027
|
||||
if ( jQuery.attr( elem, "data-" + name ) ) {
|
||||
jQuery.removeAttr( elem, "data-" + name );
|
||||
}
|
||||
|
||||
// If there is no data left in the cache, we want to continue
|
||||
// and let the cache object itself get destroyed
|
||||
if ( !isEmptyDataObject(thisCache) ) {
|
||||
|
@ -568,7 +568,7 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert
|
||||
"some-json": '{ "foo": "bar" }'
|
||||
};
|
||||
|
||||
expect( 27 );
|
||||
expect( 29 );
|
||||
|
||||
jQuery.each( datas, function( key, val ) {
|
||||
div.data( key, val );
|
||||
@ -581,4 +581,15 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert
|
||||
equal( div.data( key ), undefined, "get: " + key );
|
||||
|
||||
});
|
||||
|
||||
div.remove();
|
||||
|
||||
// Covers #10027
|
||||
div = jQuery("<div data-msg='hello'></div>");
|
||||
|
||||
equal( div.data("msg"), "hello", "<div data-msg='hello'></div> has expected data" );
|
||||
|
||||
div.removeData("msg");
|
||||
|
||||
equal( div.data("msg"), undefined, "data-msg removed correctly" );
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user