Created
December 16, 2011 02:37
-
-
Save notmasteryet/1484177 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 = {}); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment