From d18b2a8e733995d9274285c7bc0c2b59f625607e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 16 Nov 2017 15:03:45 +0100 Subject: [PATCH] Remove the `classList` polyfill This is only relevant for browsers that we don't intend to support with PDF.js version `2.0`. --- src/shared/compatibility.js | 68 ------------------------------------- 1 file changed, 68 deletions(-) diff --git a/src/shared/compatibility.js b/src/shared/compatibility.js index b2d6bcfca..f762e76e9 100644 --- a/src/shared/compatibility.js +++ b/src/shared/compatibility.js @@ -143,74 +143,6 @@ PDFJS.compatibilityChecked = true; }); })(); -// HTMLElement classList property -// Support: IE<10, Android<4.0, iOS<5.0 -(function checkClassListProperty() { - function changeList(element, itemName, add, remove) { - var s = element.className || ''; - var list = s.split(/\s+/g); - if (list[0] === '') { - list.shift(); - } - var index = list.indexOf(itemName); - if (index < 0 && add) { - list.push(itemName); - } - if (index >= 0 && remove) { - list.splice(index, 1); - } - element.className = list.join(' '); - return (index >= 0); - } - - if (!hasDOM) { - return; - } - - var div = document.createElement('div'); - if ('classList' in div) { - return; // classList property exists - } - - var classListPrototype = { - add(name) { - changeList(this.element, name, true, false); - }, - contains(name) { - return changeList(this.element, name, false, false); - }, - remove(name) { - changeList(this.element, name, false, true); - }, - toggle(name) { - changeList(this.element, name, true, true); - }, - }; - - Object.defineProperty(HTMLElement.prototype, 'classList', { - get() { - if (this._classList) { - return this._classList; - } - - var classList = Object.create(classListPrototype, { - element: { - value: this, - writable: false, - enumerable: true, - }, - }); - Object.defineProperty(this, '_classList', { - value: classList, - writable: false, - enumerable: false, - }); - return classList; - }, - enumerable: true, - }); -})(); - // Check onclick compatibility in Opera // Support: Opera<15 (function checkOnClickCompatibility() {