Remove the classList polyfill

This is only relevant for browsers that we don't intend to support with PDF.js version `2.0`.
This commit is contained in:
Jonas Jenwald 2017-11-16 15:03:45 +01:00
parent 4b15e8566b
commit d18b2a8e73

View File

@ -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() {