PageSourceSearch

https://leatherworksinc.com/cdn/shop/t/37/assets/a11y-fixes.js?v=156821873314606939671786688881

js leatherworksinc.com collected 2026-10-03 21:35:14 UTC 12,024 bytes, 2 lines download raw bytes

1(function(window2,document2){"use strict";var NS="lw-a11y",DEBUG=/[?&]a11ydebug=1/.test(window2.location.search),CONSENT_TAG="csm-cookie-consent",FOCUSABLE=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]'].join(",");function log(){if(!(!DEBUG||!window2.console)){var a=Array.prototype.slice.call(arguments);a.unshift("["+NS+"]"),window2.console.log.apply(window2.console,a)}}function ready(fn){document2.readyState==="loading"?document2.addEventListener("DOMContentLoaded",fn):fn()}function waitFor(getter,timeout,interval){return timeout=timeout||15e3,interval=interval||200,new Promise(function(resolve){var hit=getter();if(hit)return resolve(hit);var waited=0,id=window2.setInterval(function(){waited+=interval;var el=getter();(el||waited>=timeout)&&(window2.clearInterval(id),resolve(el||null))},interval)})}function visible(el){return!!(el&&(el.offsetWidth>0||el.offsetHeight>0||el.getClientRects().length))}function deepActiveElement(){for(var el=document2.activeElement;el&&el.shadowRoot&&el.shadowRoot.activeElement;)el=el.shadowRoot.activeElement;return el}var liveRegion=(function(){var ownText=null;function hidden(el){el.style.cssText="position:absolute!important;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0;"}return{ensure:function(){var node=document2.getElementById("ada-cart-qty-live");if(node){var ours=document2.getElementById(NS+"-live");ours&&ours!==node&&ours.parentNode.removeChild(ours)}else node=document2.getElementById(NS+"-live");return node||(node=document2.createElement("div"),node.id=NS+"-live",hidden(node),document2.body.appendChild(node)),node.getAttribute("role")||node.setAttribute("role","status"),node.getAttribute("aria-live")||node.setAttribute("aria-live","polite"),node.getAttribute("aria-atomic")||node.setAttribute("aria-atomic","true"),node},announce:function(message,options){var node=this.ensure(),deferrable=!!(options&&options.deferIfBusy);window2.setTimeout(function(){if(deferrable){var existing=(node.textContent||"").trim();if(existing&&existing!==ownText){log("suppressed:",message);return}}node.textContent="",window2.setTimeout(function(){ownText=message,node.textContent=message,log("announced:",message)},120)},deferrable?400:0)}}})();function createFocusTrap(options){var scope=options.scope,exempt=options.exempt||null,onEscape=options.onEscape||null,active=!1,previousFocus=null,mutatedSiblings=[],previousOverflow="",keyHandler=null;function focusables(){return Array.prototype.filter.call(scope.querySelectorAll(FOCUSABLE),visible)}return{isActive:function(){return active},activate:function(returnFocusTo){active||(active=!0,previousFocus=returnFocusTo||deepActiveElement(),Array.prototype.forEach.call(document2.body.children,function(child){exempt&&(child===exempt||child.contains(exempt))||child.hasAttribute("aria-hidden")||child.hasAttribute("inert")||(child.setAttribute("inert",""),child.setAttribute("aria-hidden","true"),mutatedSiblings.push(child))}),previousOverflow=document2.body.style.overflow,document2.body.style.overflow="hidden",keyHandler=function(event){if(event.key==="Escape"||event.keyCode===27){onEscape&&(event.preventDefault(),onEscape());return}if(!(event.key!=="Tab"&&event.keyCode!==9)){var items=focusables();if(items.length){var first=items[0],last=items[items.length-1],current=deepActiveElement();event.shiftKey&&(current===first||!scope.contains(current))?(event.preventDefault(),last.focus()):!event.shiftKey&&current===last&&(event.preventDefault(),first.focus())}}},document2.addEventListener("keydown",keyHandler,!0),window2.setTimeout(function(){var items=focusables();items.length&&items[0].focus()},60))},release:function(){if(active){if(active=!1,mutatedSiblings.forEach(function(el){el.removeAttribute("inert"),el.removeAttribute("aria-hidden")}),mutatedSiblings=[],document2.body.style.overflow=previousOverflow,keyHandler&&(document2.removeEventListener("keydown",keyHandler,!0),keyHandler=null),previousFocus&&document2.contains(previousFocus))try{previousFocus.focus()}catch(e){}previousFocus=null}}}}function fixRawUrlTitles(){var stripped=0,kept=0;return Array.prototype.forEach.call(document2.querySelectorAll("a[title]"),function(link){var title=(link.getAttribute("title")||"").trim();if(title){var href=(link.getAttribute("href")||"").trim(),isUrl=/^(https?:\/\/|\/\/|www\.)/i.test(title),matchesHref=href&&(title===href||title===link.href);isUrl||matchesHref?(link.removeAttribute("title"),link.setAttribute("data-"+NS+"-title-stripped","true"),stripped++):kept++}}),log("titles stripped",stripped,"kept",kept),{stripped:stripped,kept:kept}}function fixConsentModal(){var lastTrigger=null;return document2.addEventListener("click",function(event){var t=event.target;if(t&&t.closest){var candidate=t.closest('a[role="button"], button, a[href]');candidate&&!candidate.closest(CONSENT_TAG)&&(lastTrigger=candidate)}},!0),waitFor(function(){return document2.querySelector(CONSENT_TAG)}).then(function(host){if(!host)return!1;var root=host.shadowRoot;if(!root)return!1;var trap=createFocusTrap({scope:root,exempt:host,onEscape:function(){dismiss()}});function dismiss(){var closeBtn=root.querySelector('button[aria-label="Close"], [data-'+NS+"-close]");if(closeBtn){closeBtn.click();return}try{window2.Consentmo.closeDialog()}catch(e){}}function ensureCloseControl(dialog){if(root.querySelector('button[aria-label="Close"], [data-'+NS+"-close]"))return!1;var btn=document2.createElement("button");return btn.type="button",btn.setAttribute("aria-label","Close consent preferences"),btn.setAttribute("data-"+NS+"-close","true"),btn.textContent="\u2715",btn.style.cssText="position:absolute;top:8px;right:8px;z-index:10;background:transparent;border:0;font-size:20px;line-height:1;cursor:pointer;padding:8px;color:inherit;",btn.addEventListener("click",function(){try{window2.Consentmo.closeDialog()}catch(e){dialog.style.display="none"}}),getComputedStyle(dialog).position==="static"&&(dialog.style.position="relative"),dialog.appendChild(btn),!0}function openDialog(){var dialog=root.querySelector('[role="dialog"]');return dialog&&visible(dialog)?dialog:null}var wasOpen=!1;function sync(){var dialog=openDialog();dialog&&!wasOpen?(wasOpen=!0,ensureCloseControl(dialog),!dialog.getAttribute("aria-label")&&!dialog.getAttribute("aria-labelledby")&&dialog.setAttribute("aria-label","Consent preferences"),trap.activate(lastTrigger)):!dialog&&wasOpen&&(wasOpen=!1,trap.release()
1)}return new MutationObserver(sync).observe(root,{childList:!0,subtree:!0,attributes:!0}),new MutationObserver(sync).observe(host,{attributes:!0,attributeFilter:["style","class"]}),sync(),window2[NS].consentTrap=trap,!0})}function fixConsentTriggerKeyboard(){var fixed=0;return Array.prototype.forEach.call(document2.querySelectorAll('a[role="button"]'),function(el){el.getAttribute("href")||el.getAttribute("data-"+NS+"-keyfix")!=="true"&&(el.addEventListener("keydown",function(event){var isEnter=event.key==="Enter"||event.keyCode===13,isSpace=event.key===" "||event.key==="Spacebar"||event.keyCode===32;!isEnter&&!isSpace||(event.preventDefault(),event.stopPropagation(),el.click())}),el.setAttribute("data-"+NS+"-keyfix","true"),fixed++)}),fixed}function announceFromAddResponse(payload){if(payload){var name=payload.product_title||payload.title||"";name&&payload.product_title&&payload.variant_title&&(name=payload.product_title),liveRegion.announce(name?name+" added to your cart.":"Item added to your cart.")}}function announceFromCartResponse(payload){if(!(!payload||typeof payload.item_count!="number")){var n=payload.item_count;liveRegion.announce(n===0?"Your cart is now empty.":"Cart updated. "+n+(n===1?" item":" items")+" in your cart.",{deferIfBusy:!0})}}function isAddUrl(url){return/\/cart\/add(\.js)?(\?|$)/.test(url)}function isMutateUrl(url){return/\/cart\/(change|update|clear)\.js/.test(url)}var fetchWrapped=!1,xhrWrapped=!1;function fixCartAnnouncementsFetch(){if(typeof window2.fetch!="function"||fetchWrapped||window2.fetch.__lwA11yWrapped)return!1;var original=window2.fetch,wrapped=function(input){var url="";try{url=typeof input=="string"?input:input&&input.url||""}catch(e){url=""}var promise=original.apply(this,arguments);return!isAddUrl(url)&&!isMutateUrl(url)||promise.then(function(response){return response.ok?response.clone().json():null}).then(function(data){data&&(isAddUrl(url)?announceFromAddResponse(data):announceFromCartResponse(data))}).catch(function(){}),promise};return wrapped.__lwA11yWrapped=!0,window2.fetch=wrapped,fetchWrapped=!0,!0}function fixCartAnnouncementsXHR(){var proto=window2.XMLHttpRequest&&window2.XMLHttpRequest.prototype;if(!proto||xhrWrapped||proto.open.__lwA11yWrapped)return!1;var originalOpen=proto.open,originalSend=proto.send,patchedOpen=function(method,url){return this.__lwUrl=String(url||""),originalOpen.apply(this,arguments)};return patchedOpen.__lwA11yWrapped=!0,proto.open=patchedOpen,proto.send=function(){var xhr=this,url=xhr.__lwUrl||"";return(isAddUrl(url)||isMutateUrl(url))&&xhr.addEventListener("load",function(){if(!(xhr.status<200||xhr.status>=300)){var data=null;try{data=JSON.parse(xhr.responseText)}catch(e){return}isAddUrl(url)?announceFromAddResponse(data):announceFromCartResponse(data)}}),originalSend.apply(this,arguments)},xhrWrapped=!0,!0}function fixCartDrawer(){var drawer=document2.querySelector("#CartDrawer");if(!drawer)return!1;if(drawer.getAttribute("role")||drawer.setAttribute("role","dialog"),drawer.getAttribute("aria-modal")||drawer.setAttribute("aria-modal","true"),!drawer.getAttribute("aria-label")&&!drawer.getAttribute("aria-labelledby")){var heading=drawer.querySelector("h1,h2,h3,.drawer__title");heading?(heading.id||(heading.id=NS+"-drawer-title"),drawer.setAttribute("aria-labelledby",heading.id)):drawer.setAttribute("aria-label","Shopping cart")}var trap=createFocusTrap({scope:drawer,exempt:drawer,onEscape:function(){var close=drawer.querySelector('.drawer__close-button, button[class*="close"], [data-drawer-close]');close&&close.click()}}),wasOpen=!1;return new MutationObserver(function(){var open=/drawer--is-open|is-open/.test(drawer.className);open&&!wasOpen?(wasOpen=!0,trap.activate()):!open&&wasOpen&&(wasOpen=!1,trap.release())}).observe(drawer,{attributes:!0,attributeFilter:["class"]}),window2[NS].drawerTrap=trap,!0}function fixDuplicateIds(){var seen={},renamed=0,hidden=0;Array.prototype.forEach.call(document2.querySelectorAll("[id]"),function(el){var id=el.id;if(id){if(!seen[id]){seen[id]=1;return}seen[id]+=1,el.id=id+"--dup"+seen[id],renamed++}});var addButtons=document2.querySelectorAll('button[name="add"], input[name="add"]');return addButtons.length>1&&Array.prototype.forEach.call(addButtons,function(el){visible(el)||(el.setAttribute("aria-hidden","true"),el.setAttribute("tabindex","-1"),hidden++)}),{renamed:renamed,hidden:hidden}}
1function init(){window2[NS]=window2[NS]||{},liveRegion.ensure();var results={rawUrlTitles:fixRawUrlTitles(),consentTriggerKeyboard:fixConsentTriggerKeyboard(),cartDrawer:fixCartDrawer(),duplicateIds:fixDuplicateIds()};fixConsentModal(),window2.setTimeout(function(){window2[NS].secondPass={rawUrlTitles:fixRawUrlTitles(),consentTriggerKeyboard:fixConsentTriggerKeyboard(),duplicateIds:fixDuplicateIds()}},2500),window2[NS].version="2026-07-28",window2[NS].results=results,window2[NS].fixes={fixRawUrlTitles:fixRawUrlTitles,fixConsentModal:fixConsentModal,fixConsentTriggerKeyboard:fixConsentTriggerKeyboard,fixCartAnnouncementsFetch:fixCartAnnouncementsFetch,fixCartAnnouncementsXHR:fixCartAnnouncementsXHR,fixCartDrawer:fixCartDrawer,fixDuplicateIds:fixDuplicateIds,createFocusTrap:createFocusTrap,liveRegion:liveRegion},log("init",results)}fixCartAnnouncementsFetch(),fixCartAnnouncementsXHR(),ready(init)})(window,document);
2//# sourceMappingURL=/cdn/shop/t/37/assets/a11y-fixes.js.map?v=156821873314606939671786688881

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.