More Details:
- https://github.com/jquery/jquery/pull/461
- http://bugs.jquery.com/ticket/10026
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) ) {
"some-json": '{ "foo": "bar" }'
};
- expect( 27 );
+ expect( 29 );
jQuery.each( datas, function( key, val ) {
div.data( key, val );
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" );
});