New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@zag-js/aria-hidden

Package Overview
Dependencies
Maintainers
1
Versions
713
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/aria-hidden - npm Package Compare versions

Comparing version 0.78.1 to 0.78.2

112

dist/index.js
'use strict';
var ariaHidden$1 = require('aria-hidden');
// src/walk-tree-outside.ts
var counterMap = /* @__PURE__ */ new WeakMap();
var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
var markerMap = {};
var lockCount = 0;
var unwrapHost = (node) => node && (node.host || unwrapHost(node.parentNode));
var correctTargets = (parent, targets) => targets.map((target) => {
if (parent.contains(target)) return target;
const correctedTarget = unwrapHost(target);
if (correctedTarget && parent.contains(correctedTarget)) {
return correctedTarget;
}
console.error("[zag-js > ariaHidden] target", target, "in not contained inside", parent, ". Doing nothing");
return null;
}).filter((x) => Boolean(x));
var isIgnoredNode = (node) => {
if (node.localName === "next-route-announcer") return true;
if (node.localName === "script") return true;
if (node.hasAttribute("aria-live")) return true;
return node.matches("[data-live-announcer]");
};
var walkTreeOutside = (originalTarget, props) => {
const { parentNode, markerName, controlAttribute } = props;
const targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
markerMap[markerName] || (markerMap[markerName] = /* @__PURE__ */ new WeakMap());
const markerCounter = markerMap[markerName];
const hiddenNodes = [];
const elementsToKeep = /* @__PURE__ */ new Set();
const elementsToStop = new Set(targets);
const keep = (el) => {
if (!el || elementsToKeep.has(el)) return;
elementsToKeep.add(el);
keep(el.parentNode);
};
targets.forEach(keep);
const deep = (parent) => {
if (!parent || elementsToStop.has(parent)) {
return;
}
Array.prototype.forEach.call(parent.children, (node) => {
if (elementsToKeep.has(node)) {
deep(node);
} else {
try {
if (isIgnoredNode(node)) return;
const attr = node.getAttribute(controlAttribute);
const alreadyHidden = attr !== null && attr !== "false";
const counterValue = (counterMap.get(node) || 0) + 1;
const markerValue = (markerCounter.get(node) || 0) + 1;
counterMap.set(node, counterValue);
markerCounter.set(node, markerValue);
hiddenNodes.push(node);
if (counterValue === 1 && alreadyHidden) {
uncontrolledNodes.set(node, true);
}
if (markerValue === 1) {
node.setAttribute(markerName, "");
}
if (!alreadyHidden) {
node.setAttribute(controlAttribute, "");
}
} catch (e) {
console.error("[zag-js > ariaHidden] cannot operate on ", node, e);
}
}
});
};
deep(parentNode);
elementsToKeep.clear();
lockCount++;
return () => {
hiddenNodes.forEach((node) => {
const counterValue = counterMap.get(node) - 1;
const markerValue = markerCounter.get(node) - 1;
counterMap.set(node, counterValue);
markerCounter.set(node, markerValue);
if (!counterValue) {
if (!uncontrolledNodes.has(node)) {
node.removeAttribute(controlAttribute);
}
uncontrolledNodes.delete(node);
}
if (!markerValue) {
node.removeAttribute(markerName);
}
});
lockCount--;
if (!lockCount) {
counterMap = /* @__PURE__ */ new WeakMap();
counterMap = /* @__PURE__ */ new WeakMap();
uncontrolledNodes = /* @__PURE__ */ new WeakMap();
markerMap = {};
}
};
};
// src/aria-hidden.ts
var getParentNode = (originalTarget) => {
const target = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
return target.ownerDocument.body;
};
var hideOthers = (originalTarget, parentNode = getParentNode(originalTarget), markerName = "data-aria-hidden") => {
if (!parentNode) return;
return walkTreeOutside(originalTarget, {
parentNode,
markerName,
controlAttribute: "aria-hidden"
});
};
// src/index.ts

@@ -19,3 +127,3 @@ var raf = (fn) => {

if (elements.length === 0) return;
cleanups.push(ariaHidden$1.hideOthers(elements));
cleanups.push(hideOthers(elements));
})

@@ -22,0 +130,0 @@ );

5

package.json
{
"name": "@zag-js/aria-hidden",
"version": "0.78.1",
"version": "0.78.2",
"description": "Hide targets from screen readers",

@@ -26,5 +26,2 @@ "keywords": [

"main": "dist/index.js",
"dependencies": {
"aria-hidden": "1.2.4"
},
"devDependencies": {

@@ -31,0 +28,0 @@ "clean-package": "2.2.0"

Sorry, the diff of this file is not supported yet

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