Test case for jQuery Ticket 8191

data-* attributes and removeData

by jitter

HTML

<p id="one" data-one="1"></p>














<script src="https://getfirebug.com/firebug-lite.js">
    {
    overrideConsole: false,
        startOpened: true
    }
</script>

JavaScript

var one = $("#one");

function log() {
    console.log( jQuery.extend( {}, one.data() ));
}

log();

/*
//you can uncomment this block this get a better picture how data and data-* attributes work together
one.data("data-one", "2");
log();

one.data("one", "3");
log();

one.data("data-two", "two");
log();

one.data("two", "two too");
log();
*/
    
one.removeData();

//log still shows one=1 here which is correct.
//We don't (and shouldn't not) remove the HTML attribute data-one="1"
log();

/*
//if you want no "data" left on the element you need to remove the attribute after calling removeData
one.removeData();
one.removeAttr("data-one");
log();
*/