Tweak the DOMTokenList.toggle
polyfill (issue 10460)
This commit is contained in:
parent
5cb00b7967
commit
68ad3e8e9d
@ -101,14 +101,17 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
|
|||||||
if (div.classList.toggle('test', 0) === false) {
|
if (div.classList.toggle('test', 0) === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const originalDOMTokenListToggle = DOMTokenList.prototype.toggle;
|
|
||||||
|
|
||||||
DOMTokenList.prototype.toggle = function(token) {
|
DOMTokenList.prototype.toggle = function(token) {
|
||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
const force = !!arguments[1];
|
const force = !!arguments[1];
|
||||||
return (this[force ? 'add' : 'remove'](token), force);
|
return (this[force ? 'add' : 'remove'](token), force);
|
||||||
}
|
}
|
||||||
return originalDOMTokenListToggle(token);
|
|
||||||
|
if (this.contains(token)) {
|
||||||
|
return (this.remove(token), false);
|
||||||
|
}
|
||||||
|
return (this.add(token), true);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ class PDFFindBar {
|
|||||||
}
|
}
|
||||||
Promise.resolve(matchesCountMsg).then((msg) => {
|
Promise.resolve(matchesCountMsg).then((msg) => {
|
||||||
this.findResultsCount.textContent = msg;
|
this.findResultsCount.textContent = msg;
|
||||||
this.findResultsCount.classList[!total ? 'add' : 'remove']('hidden');
|
this.findResultsCount.classList.toggle('hidden', !total);
|
||||||
// Since `updateResultsCount` may be called from `PDFFindController`,
|
// Since `updateResultsCount` may be called from `PDFFindController`,
|
||||||
// ensure that the width of the findbar is always updated correctly.
|
// ensure that the width of the findbar is always updated correctly.
|
||||||
this._adjustWidth();
|
this._adjustWidth();
|
||||||
|
Loading…
Reference in New Issue
Block a user