File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,11 @@ jQuery.extend({
167167
168168 delete thisCache [ name ] ;
169169
170+ // Check the actual element for predefined data-* attrs, #10027
171+ if ( jQuery . attr ( elem , "data-" + name ) ) {
172+ jQuery . removeAttr ( elem , "data-" + name ) ;
173+ }
174+
170175 // If there is no data left in the cache, we want to continue
171176 // and let the cache object itself get destroyed
172177 if ( ! isEmptyDataObject ( thisCache ) ) {
Original file line number Diff line number Diff line change @@ -568,7 +568,7 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert
568568 "some-json" : '{ "foo": "bar" }'
569569 } ;
570570
571- expect ( 27 ) ;
571+ expect ( 29 ) ;
572572
573573 jQuery . each ( datas , function ( key , val ) {
574574 div . data ( key , val ) ;
@@ -581,4 +581,15 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert
581581 equal ( div . data ( key ) , undefined , "get: " + key ) ;
582582
583583 } ) ;
584+
585+ div . remove ( ) ;
586+
587+ // Covers #10027
588+ div = jQuery ( "<div data-msg='hello'></div>" ) ;
589+
590+ equal ( div . data ( "msg" ) , "hello" , "<div data-msg='hello'></div> has expected data" ) ;
591+
592+ div . removeData ( "msg" ) ;
593+
594+ equal ( div . data ( "msg" ) , undefined , "data-msg removed correctly" ) ;
584595} ) ;
You can’t perform that action at this time.
0 commit comments