epiphany/node_modules/postcss-focus-within/dist/browser.cjs
2023-12-09 22:48:07 -08:00

2 lines
1.4 KiB
JavaScript

var e=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(t){for(var n=!0,c=0,i=e.length;c<i&&n;c++)t.indexOf(e[c])>-1&&(n=!1);return n}module.exports=function focusWithin(e){var t={force:!1,replaceWith:"[focus-within]"};if(void 0!==e&&"force"in e&&(t.force=e.force),void 0!==e&&"replaceWith"in e&&(t.replaceWith=e.replaceWith),!isValidReplacement(t.replaceWith))throw new Error(t.replaceWith+" is not a valid replacement since it can't be applied to single elements.");try{if(document.querySelector(":focus-within"),!t.force)return}catch(d){}var n,c,i,o,r,a=(n=t.replaceWith,r=[],"."===n[0]?(c=n.slice(1),i=function remove(e){return e.classList.remove(c)},o=function add(e){return e.classList.add(c)}):(c=n.slice(1,-1),i=function remove(e){return e.removeAttribute(c,"")},o=function add(e){return e.setAttribute(c,"")}),function handleFocusChange(){r.forEach((function(e){return i(e)})),r.length=0;var e=document.activeElement;if(!/^(#document|HTML|BODY)$/.test(Object(e).nodeName))for(;e&&1===e.nodeType;)o(e),r.push(e),e=e.parentNode}),u=function initializeEventListeners(){document.documentElement.className.indexOf("js-focus-within")>-1||(document.documentElement.className=document.documentElement.className+" js-focus-within",document.addEventListener("focus",a,!0),document.addEventListener("blur",a,!0))};"complete"===document.readyState?u():document.addEventListener("DOMContentLoaded",u)};
//# sourceMappingURL=browser.cjs.map