From d6e4607fd039c0f2ccb7c863d048cd4d9235ec9d Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Thu, 15 Dec 2011 20:44:55 -0600 Subject: [PATCH] Add compatibility for HTMLElement's dataset (#945) --- web/compatibility.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web/compatibility.js b/web/compatibility.js index 7d1d72553..e4e2f2440 100644 --- a/web/compatibility.js +++ b/web/compatibility.js @@ -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 = {}); + } + }); +})();