1/** 2 * Invision Community 3 * (c) Invision Power Services, Inc. - https://www.invisioncommunity.com 4 * 5 * This polyfill is used to fix numerous popover quirks in Safari 6 * 7 * Author: Ehren Harber 8 */ 9 10// #1. Store the trigger as a property since Safari doesn't support e.source. Last checked in 26.1 11// #2. Fix a bug where the browser freezes when an input in a popover gains/loses focus. Fixed in 18.4 12// #3. Fix a bug where popovers aren't light-dismissed on iOS and iPadOS. Fixed in 18.3 13// #4. Fix a bug where popovertarget buttons fail inside forms. Fixed in 18.2 14 15// Toggle popover using API (1, 2) 16document.addEventListener("click", safariTogglePopoverFix); 17 18function safariTogglePopoverFix(e){ 19 // Get trigger (1, 2) 20 const trigger = e.target.closest("[popovertarget]"); 21 if(!trigger) return; 22 // Get popover (1, 2) 23 const popoverEl = document.querySelector(`#${trigger.getAttribute("popovertarget")}`); 24 if(!popoverEl) return; 25 // Safari doesn't support e.source, so we need to manually add it as a property so we can reference it later (1) 26 popoverEl.safariTrigger = trigger; 27 if( 28 // Target 18.3 and below (2) 29 (!CSS.supports("selector(::details-content)") && popoverEl.querySelector('input:not([type="radio"], [type="checkbox"]), select')) 30 || 31 // Target 18.1 and below (4) 32 (!CSS.supports("text-box-edge: auto") && trigger.closest("form")) 33 ){ 34 e.preventDefault(); 35 popoverEl[`${trigger.popoverTargetAction || "toggle"}Popover`]({source:trigger}); 36 } 37} 38// Fixes light-dismiss (3). There's no conditional for <18.3, so we just target 18.3 and below. 39if(!CSS.supports("selector(::details-content)")){ 40 document.addEventListener("pointerdown", e => {}); 41}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.