fastclick.js (1772B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * Bug 1738220 - Shim Conversant FastClick 9 * 10 * Sites assuming FastClick will load can break if it is blocked. 11 * This shim mitigates that breakage. 12 */ 13 14 // FastClick bundles nodeJS packages/core-js/internals/dom-iterables.js 15 // which is known to be needed by at least one site. 16 if (!HTMLCollection.prototype.forEach) { 17 const DOMIterables = [ 18 "CSSRuleList", 19 "CSSStyleDeclaration", 20 "CSSValueList", 21 "ClientRectList", 22 "DOMRectList", 23 "DOMStringList", 24 "DOMTokenList", 25 "DataTransferItemList", 26 "FileList", 27 "HTMLAllCollection", 28 "HTMLCollection", 29 "HTMLFormElement", 30 "HTMLSelectElement", 31 "MediaList", 32 "MimeTypeArray", 33 "NamedNodeMap", 34 "NodeList", 35 "PaintRequestList", 36 "Plugin", 37 "PluginArray", 38 "SVGLengthList", 39 "SVGNumberList", 40 "SVGPathSegList", 41 "SVGPointList", 42 "SVGStringList", 43 "SVGTransformList", 44 "SourceBufferList", 45 "StyleSheetList", 46 "TextTrackCueList", 47 "TextTrackList", 48 "TouchList", 49 ]; 50 51 const forEach = Array.prototype.forEach; 52 53 const handlePrototype = proto => { 54 if (!proto || proto.forEach === forEach) { 55 return; 56 } 57 try { 58 Object.defineProperty(proto, "forEach", { 59 enumerable: false, 60 get: () => forEach, 61 }); 62 } catch (_) { 63 proto.forEach = forEach; 64 } 65 }; 66 67 for (const name of DOMIterables) { 68 handlePrototype(window[name]?.prototype); 69 } 70 } 71 72 if (!window.conversant?.launch) { 73 const c = (window.conversant = window.conversant || {}); 74 c.launch = () => {}; 75 }