MCPcopy Create free account
hub / github.com/microsoft/SandDance / modalize

Function modalize

docs/app/js/sanddance-app.js:25673–25696  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

25671 * That way, all other elements on the page are hidden to the screen reader.
25672 */ var _getDocument = require("./dom/getDocument");
25673function modalize(target) {
25674 var _a;
25675 var affectedNodes = [];
25676 var targetDocument = (0, _getDocument.getDocument)(target) || document;
25677 // start at target, then recurse and do the same for parent, until we reach <body>
25678 while(target !== targetDocument.body){
25679 // grab all siblings of current element
25680 for(var _i = 0, _b = target.parentElement.children; _i < _b.length; _i++){
25681 var sibling = _b[_i];
25682 // but ignore elements that are already aria-hidden
25683 if (sibling !== target && ((_a = sibling.getAttribute("aria-hidden")) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== "true") affectedNodes.push(sibling);
25684 }
25685 if (!target.parentElement) break;
25686 target = target.parentElement;
25687 }
25688 // take all those elements and set aria-hidden=true on them
25689 affectedNodes.forEach(function(node) {
25690 node.setAttribute("aria-hidden", "true");
25691 });
25692 return function() {
25693 unmodalize(affectedNodes);
25694 affectedNodes = []; // dispose
25695 };
25696}
25697/**
25698 * Undoes the changes that modalize() did.
25699 */ function unmodalize(affectedNodes) {

Callers

nothing calls this directly

Calls 2

unmodalizeFunction · 0.85
forEachMethod · 0.45

Tested by

no test coverage detected