DevTools: mimic DOMTokenList.toggle override in DOMExtension
Change-Id: If67b9b070d6ad59a68a54fe99ff0a601da4b4e1d
Reviewed-on: https://chromium-review.googlesource.com/c/1354780
Commit-Queue: Pavel Feldman <[email protected]>
Reviewed-by: Aleksey Kozyatinskiy <[email protected]>
Reviewed-by: Dmitry Gozman <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#616514}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: d19bf8249bbbdd524c5a074b32289631b4aff21b
diff --git a/front_end/devtools_compatibility.js b/front_end/devtools_compatibility.js
index 8ff215b..7627ba2 100644
--- a/front_end/devtools_compatibility.js
+++ b/front_end/devtools_compatibility.js
@@ -1262,6 +1262,17 @@
return fakeConstructor();
return origCreateElement.call(this, tagName, fakeCustomElementType);
};
+
+ // DevTools front-ends mistakenly assume that
+ // classList.toggle('a', undefined) works as
+ // classList.toggle('a', false) rather than as
+ // classList.toggle('a');
+ const originalDOMTokenListToggle = DOMTokenList.prototype.toggle;
+ DOMTokenList.prototype.toggle = function(token, force) {
+ if (arguments.length === 1)
+ force = !this.contains(token);
+ return originalDOMTokenListToggle.call(this, token, !!force);
+ };
}
if (majorVersion <= 66) {
@@ -1406,21 +1417,4 @@
installBackwardsCompatibility();
- /** @type {(!function(string, boolean=):boolean)|undefined} */
- DOMTokenList.prototype.__originalDOMTokenListToggle;
-
- if (!DOMTokenList.prototype.__originalDOMTokenListToggle) {
- DOMTokenList.prototype.__originalDOMTokenListToggle = DOMTokenList.prototype.toggle;
- /**
- * @param {string} token
- * @param {boolean=} force
- * @return {boolean}
- */
- DOMTokenList.prototype.toggle = function(token, force) {
- if (arguments.length === 1)
- force = !this.contains(token);
- return this.__originalDOMTokenListToggle(token, !!force);
- };
- }
-
})(window);