From: notmasteryet Date: Fri, 16 Dec 2011 02:44:55 +0000 (-0600) Subject: Add compatibility for HTMLElement's dataset (#945) X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d6e4607fd039c0f2ccb7c863d048cd4d9235ec9d;p=pdf.js.git Add compatibility for HTMLElement's dataset (#945) --- diff --git a/web/compatibility.js b/web/compatibility.js index 7d1d725..e4e2f24 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 = {}); + } + }); +})();