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({
167
167
168
168
delete thisCache [ name ] ;
169
169
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
+
170
175
// If there is no data left in the cache, we want to continue
171
176
// and let the cache object itself get destroyed
172
177
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
568
568
"some-json" : '{ "foo": "bar" }'
569
569
} ;
570
570
571
- expect ( 27 ) ;
571
+ expect ( 29 ) ;
572
572
573
573
jQuery . each ( datas , function ( key , val ) {
574
574
div . data ( key , val ) ;
@@ -581,4 +581,15 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert
581
581
equal ( div . data ( key ) , undefined , "get: " + key ) ;
582
582
583
583
} ) ;
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" ) ;
584
595
} ) ;
You can’t perform that action at this time.
0 commit comments