Socket
Socket
Sign inDemoInstall

@finsweet/attributes-a11y

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@finsweet/attributes-a11y - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

2

a11y.js

@@ -1,1 +0,1 @@

"use strict";(()=>{var k=Object.create;var _=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var Y=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var j=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of D(e))!F.call(t,r)&&r!==s&&_(t,r,{get:()=>e[r],enumerable:!(i=M(e,r))||i.enumerable});return t};var H=(t,e,s)=>(s=t!=null?k($(t)):{},j(e||!t||!t.__esModule?_(s,"default",{value:t,enumerable:!0}):s,t));var B=Y((Lt,g)=>{g.exports=J;function J(t,e,s,i){var r,o,n;return function(){if(n=this,o=Array.prototype.slice.call(arguments),r&&(s||i))return;if(!s)return c(),r=setTimeout(u,e),r;r=setTimeout(c,e),t.apply(n,o);function u(){c(),t.apply(n,o)}function c(){clearTimeout(r),r=null}}}});var p="fs-attributes",l="a11y";var T=t=>{let e=(i,r,o)=>{let n=t[i],{key:a,values:u}=n,c;if(!r)return`[${a}]`;let d=u==null?void 0:u[r];typeof d=="string"?c=d:c=d(o&&"instanceIndex"in o?o.instanceIndex:void 0);let A=o&&"caseInsensitive"in o&&o.caseInsensitive?"i":"";if(!(o!=null&&o.operator))return`[${a}="${c}"${A}]`;switch(o.operator){case"prefixed":return`[${a}^="${c}"${A}]`;case"suffixed":return`[${a}$="${c}"${A}]`;case"contains":return`[${a}*="${c}"${A}]`}};function s(i,r){let o=e("element",i,r),n=(r==null?void 0:r.scope)||document;return r!=null&&r.all?n.querySelectorAll(o):n.querySelector(o)}return[e,s]};var m={preventLoad:{key:`${p}-preventload`},debugMode:{key:`${p}-debug`},src:{key:"src",values:{finsweet:"@finsweet/attributes"}},dev:{key:`${p}-dev`}},[f,at]=T(m);var R=t=>{let{currentScript:e}=document,s={};if(!e)return{attributes:s,preventsLoad:!1};let r={preventsLoad:typeof e.getAttribute(m.preventLoad.key)=="string",attributes:s};for(let o in t){let n=e.getAttribute(t[o]);r.attributes[o]=n}return r};var x=(t,e)=>(Array.isArray(e)||(e=[e]),e.map(i=>t.dispatchEvent(new Event(i,{bubbles:!0}))).every(i=>i));var E=t=>!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length);var q=`${p}-support`,X="https://cdn.jsdelivr.net/npm/@finsweet/attributes-support@1/support.js",y=async()=>{let{fsAttributes:t,location:e}=window,{host:s,searchParams:i}=new URL(e.href);if(!s.includes("webflow.io")||!i.has(q))return!1;if(t.supportImport)return t.supportImport;try{t.supportImport=new Promise((r,o)=>{let n=document.createElement("script");n.src=X,n.onload=()=>r(!0),n.onerror=o,document.head.append(n)})}catch(r){return!1}return t.supportImport};var S=()=>{if(window.fsAttributes&&!Array.isArray(window.fsAttributes))return;let t={cms:{},push(...e){var s,i;for(let[r,o]of e)(i=(s=this[r])==null?void 0:s.loading)==null||i.then(o)}};G(t),W(t),window.fsAttributes=t,window.FsAttributes=window.fsAttributes,y()},G=t=>{let e=f("src","finsweet",{operator:"contains"}),s=f("dev"),r=[...document.querySelectorAll(`script${e}, script${s}`)].reduce((o,n)=>{var u;let a=n.getAttribute(m.dev.key)||((u=n.src.match(/[\w-. ]+(?=(\.js)$)/))==null?void 0:u[0]);return a&&!o.includes(a)&&o.push(a),o},[]);for(let o of r){t[o]={};let n=t[o];n.loading=new Promise(a=>{n.resolve=u=>{a(u),delete n.resolve}})}},W=t=>{let e=Array.isArray(window.fsAttributes)?window.fsAttributes:[];t.push(...e)};var w="0.1.3";var v="tabindex";var U="aria-expanded";var b="aria-controls";var L=H(B(),1);var z=`fs-${l}`,Z="autofocus",tt={element:{key:`${z}-element`,values:{autoFocus:Z}}},[Pt,C]=T(tt);var O=()=>{let t=document.querySelectorAll(`[${b}]`);for(let e of t)et(e)},et=t=>{let e=t.getAttribute(b);if(!e)return;let s=document.getElementById(e);if(!s){t.removeAttribute(b);return}let i=C("autoFocus",{operator:"prefixed",scope:s}),r=E(s);h(t,r);let n=(0,L.default)(u=>{u.forEach(()=>{let c=E(s);h(t,c),i&&!r&&c&&i.focus(),r=c})},100);new MutationObserver(n).observe(s,{attributes:!0,attributeFilter:["style","class"]})},h=(t,e)=>{t.setAttribute(U,`${e}`)};var K=()=>{window.addEventListener("keydown",({target:t,key:e})=>{e!=="Enter"&&e!==" "||(t instanceof HTMLDivElement||t instanceof HTMLLIElement)&&(!t.getAttribute(v)||x(t,"click"))})};var I=()=>{var t,e;K(),O(),(e=(t=window.fsAttributes[l]).resolve)==null||e.call(t,void 0)};S();var P,V;(P=window.fsAttributes)[V=l]||(P[V]={});var{preventsLoad:rt}=R(),N=window.fsAttributes[l];N.version=w;rt?N.init=I:(window.Webflow||(window.Webflow=[]),window.Webflow.push(I));})();
"use strict";(()=>{var Y=Object.create;var y=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var X=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var q=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of F(t))!j.call(e,r)&&r!==o&&y(e,r,{get:()=>t[r],enumerable:!(s=$(t,r))||s.enumerable});return e};var G=(e,t,o)=>(o=e!=null?Y(H(e)):{},q(t||!e||!e.__esModule?y(o,"default",{value:e,enumerable:!0}):o,e));var h=X((Mt,V)=>{V.exports=et;function et(e,t,o,s){var r,n,i;return function(){if(i=this,n=Array.prototype.slice.call(arguments),r&&(o||s))return;if(!o)return a(),r=setTimeout(u,t),r;r=setTimeout(a,t),e.apply(i,n);function u(){a(),e.apply(i,n)}function a(){clearTimeout(r),r=null}}}});var l="fs-attributes";var p="a11y";var I="cmsattribute";var S=async(...e)=>{var o;let t=[];for(let s of e){let r=await((o=window.fsAttributes[s])==null?void 0:o.loading);t.push(r)}return t};var A=()=>{};function x(e,t,o,s){return e?(e.addEventListener(t,o,s),()=>e.removeEventListener(t,o,s)):A}var _=(e,t)=>(Array.isArray(t)||(t=[t]),t.map(s=>e.dispatchEvent(new Event(s,{bubbles:!0}))).every(s=>s));var E=e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length);function v(e,t,o){var r;let s=window.fsAttributes[e];return s.destroy=o||A,(r=s.resolve)==null||r.call(s,t),t}var W=`${l}-support`,z="https://cdn.jsdelivr.net/npm/@finsweet/attributes-support@1/support.js",w=async()=>{let{fsAttributes:e,location:t}=window,{host:o,searchParams:s}=new URL(t.href);e.support||(e.support={});let{support:r}=e;if(!o.includes("webflow.io")||!s.has(W))return!1;if(r.import)return r.import;try{r.import=new Promise((n,i)=>{let c=document.createElement("script");c.src=z,c.onload=()=>n(!0),c.onerror=i,document.head.append(c)})}catch(n){return!1}return r.import};var d=e=>{let t=(s,r,n)=>{let i=e[s],{key:c,values:u}=i,a;if(!r)return`[${c}]`;let f=u==null?void 0:u[r];typeof f=="string"?a=f:a=f(n&&"instanceIndex"in n?n.instanceIndex:void 0);let T=n&&"caseInsensitive"in n&&n.caseInsensitive?"i":"";if(!(n!=null&&n.operator))return`[${c}="${a}"${T}]`;switch(n.operator){case"prefixed":return`[${c}^="${a}"${T}]`;case"suffixed":return`[${c}$="${a}"${T}]`;case"contains":return`[${c}*="${a}"${T}]`}};function o(s,r){let n=t("element",s,r),i=(r==null?void 0:r.scope)||document;return r!=null&&r.all?[...i.querySelectorAll(n)]:i.querySelector(n)}return[t,o]};var m={preventLoad:{key:`${l}-preventload`},debugMode:{key:`${l}-debug`},src:{key:"src",values:{finsweet:"@finsweet/attributes"}},dev:{key:`${l}-dev`}},[R,Ut]=d(m);var U=e=>{let{currentScript:t}=document,o={};if(!t)return{attributes:o,preventsLoad:!1};let r={preventsLoad:typeof t.getAttribute(m.preventLoad.key)=="string",attributes:o};for(let n in e){let i=t.getAttribute(e[n]);r.attributes[n]=i}return r};var B=({scriptAttributes:e,attributeKey:t,version:o,init:s})=>{var c;Q(),(c=window.fsAttributes)[t]||(c[t]={});let{preventsLoad:r,attributes:n}=U(e),i=window.fsAttributes[t];i.version=o,i.init=s,r||(window.Webflow||(window.Webflow=[]),window.Webflow.push(()=>s(n)))},Q=()=>{let e=J();if(window.fsAttributes&&!Array.isArray(window.fsAttributes)){g(window.fsAttributes,e);return}let t={cms:{},push(...o){var s,r;for(let[n,i]of o)(r=(s=this[n])==null?void 0:s.loading)==null||r.then(i)},destroy(){var o,s;for(let r of e)(s=(o=window.fsAttributes[r])==null?void 0:o.destroy)==null||s.call(o)}};g(t,e),Z(t),window.fsAttributes=t,window.FsAttributes=window.fsAttributes,w()},J=()=>{let e=R("src","finsweet",{operator:"contains"}),t=R("dev");return[...document.querySelectorAll(`script${e}, script${t}`)].reduce((r,n)=>{var c;let i=n.getAttribute(m.dev.key)||((c=n.src.match(/[\w-. ]+(?=(\.js)$)/))==null?void 0:c[0]);return i&&!r.includes(i)&&r.push(i),r},[])},g=(e,t)=>{for(let o of t){if(e[o])continue;e[o]={};let s=e[o];s.loading=new Promise(r=>{s.resolve=n=>{r(n),delete s.resolve}})}},Z=e=>{let t=Array.isArray(window.fsAttributes)?window.fsAttributes:[];e.push(...t)};var L="0.2.0";var C="tabindex";var K="aria-expanded";var b="aria-controls";var M=G(h(),1);var rt=`fs-${p}`,ot="autofocus",st={element:{key:`${rt}-element`,values:{autoFocus:ot}}},[Dt,O]=d(st);var N=()=>{let t=[...document.querySelectorAll(`[${b}]`)].map(nt);return()=>{for(let o of t)o==null||o.disconnect()}},nt=e=>{let t=e.getAttribute(b);if(!t)return;let o=document.getElementById(t);if(!o){e.removeAttribute(b);return}let s=O("autoFocus",{operator:"prefixed",scope:o}),r=E(o);P(e,r);let i=(0,M.default)(()=>{let u=E(o);P(e,u),s&&!r&&u&&s.focus(),r=u},100),c=new MutationObserver(i);return c.observe(o,{attributes:!0,attributeFilter:["style","class"]}),c},P=(e,t)=>{e.setAttribute(K,String(t))};var it=[HTMLAnchorElement,HTMLButtonElement,HTMLInputElement,HTMLTextAreaElement,HTMLSelectElement,HTMLVideoElement,HTMLAudioElement],k=()=>{let t=x(window,"keydown",o=>{var n;let{target:s,key:r}=o;r!=="Enter"&&r!==" "||!s||!((n=s.getAttribute)!=null&&n.call(s,C))||it.some(i=>s instanceof i)||(o.preventDefault(),_(s,"click"))});return()=>{t()}};var D=async()=>{await S(I);let e=k(),t=N();return v(p,void 0,()=>{e(),t()})};B({init:D,version:L,attributeKey:p});})();

@@ -1,1 +0,1 @@

[{"version":"v1.0.0","date":"1 January 1970","markdown":"- Created the attribute package.\n"}]
[{"version":"0.2.0","markdown":"- e4b3b680: Created new `window.fsAttributes.destroy()` method to support SPA environments.\n This new method allows users to destroy all Attributes instances, cleaning up event listeners, observers, states, global variables, etc.\n\n Websites that use a client-side router that simulates an SPA environment like [barba.js](https://barba.js.org/) or [Swup](https://swup.js.org/) can now properly init and destroy Attributes.\n After destroying, Attributes can be manually re-initted by calling `window.fsAttribute[ATTRIBUTE_KEY].init()`.\n\n Updated changesets system, now all updates will be correctly reflected in [the official updates page](https://www.finsweet.com/attributes/updates)."},{"version":"0.1.3","markdown":"- Updated dependencies [4792998a]\n - @global/constants@1.2.0\n - @global/factory@1.1.5"},{"version":"0.1.2","markdown":"- Updated dependencies [07f32375]\n - @global/constants@1.1.0\n - @global/factory@1.1.4"},{"version":"0.1.1","markdown":"- 62a2d7f3: Ensured aria-expanded is always set for aria-controls controllers"},{"version":"0.1.0","markdown":"- a14e67a5: Added aria-controls and keyboard-clicks functionalities."}]
{
"name": "@finsweet/attributes-a11y",
"version": "0.1.3",
"version": "0.2.0",
"description": "Accessibility JS solutions for Webflow.",

@@ -33,11 +33,3 @@ "homepage": "https://www.finsweet.com/attributes",

},
"devDependencies": {
"@global/build": "1.0.0",
"@global/tests": "1.0.0",
"@global/types": "1.0.0"
},
"dependencies": {
"@finsweet/ts-utils": "^0.33.1",
"@global/constants": "1.2.0",
"@global/factory": "1.1.5",
"just-debounce": "^1.1.0"

@@ -47,2 +39,3 @@ },

"dev": "cross-env NODE_ENV=development node ./bin/build.js",
"build:dev": "cross-env NODE_ENV=test node ./bin/build.js",
"build": "cross-env NODE_ENV=production node ./bin/build.js",

@@ -49,0 +42,0 @@ "lint": "eslint ./src && prettier --check ./src",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc