mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
Tweak the DOMTokenList.toggle
polyfill (issue 10460)
This commit is contained in:
parent
5cb00b7967
commit
68ad3e8e9d
2 changed files with 6 additions and 3 deletions
|
@ -101,14 +101,17 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
|
|||
if (div.classList.toggle('test', 0) === false) {
|
||||
return;
|
||||
}
|
||||
const originalDOMTokenListToggle = DOMTokenList.prototype.toggle;
|
||||
|
||||
DOMTokenList.prototype.toggle = function(token) {
|
||||
if (arguments.length > 1) {
|
||||
const force = !!arguments[1];
|
||||
return (this[force ? 'add' : 'remove'](token), force);
|
||||
}
|
||||
return originalDOMTokenListToggle(token);
|
||||
|
||||
if (this.contains(token)) {
|
||||
return (this.remove(token), false);
|
||||
}
|
||||
return (this.add(token), true);
|
||||
};
|
||||
})();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue