Add compatibility for HTMLElement's dataset (#945)

This commit is contained in:
notmasteryet 2011-12-15 20:44:55 -06:00
parent f8a38de791
commit d6e4607fd0

View File

@ -205,3 +205,15 @@
});
})();
// HTMLElement dataset property
(function checkDatasetProperty() {
var div = document.createElement('div');
if ('dataset' in div)
return; // dataset property exists
Object.defineProperty(HTMLElement.prototype, 'dataset', {
get: function htmlElementDatasetGetter() {
// adding dataset field to the actual object
return (this.dataset = {});
}
});
})();