Initial commit
This commit is contained in:
47
node_modules/react-overlays/lib/utils/manageAriaHidden.js
generated
vendored
Normal file
47
node_modules/react-overlays/lib/utils/manageAriaHidden.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.ariaHidden = ariaHidden;
|
||||
exports.hideSiblings = hideSiblings;
|
||||
exports.showSiblings = showSiblings;
|
||||
|
||||
var BLACKLIST = ['template', 'script', 'style'];
|
||||
|
||||
var isHidable = function isHidable(_ref) {
|
||||
var nodeType = _ref.nodeType,
|
||||
tagName = _ref.tagName;
|
||||
return nodeType === 1 && BLACKLIST.indexOf(tagName.toLowerCase()) === -1;
|
||||
};
|
||||
|
||||
var siblings = function siblings(container, mount, cb) {
|
||||
mount = [].concat(mount);
|
||||
|
||||
[].forEach.call(container.children, function (node) {
|
||||
if (mount.indexOf(node) === -1 && isHidable(node)) {
|
||||
cb(node);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function ariaHidden(show, node) {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
if (show) {
|
||||
node.setAttribute('aria-hidden', 'true');
|
||||
} else {
|
||||
node.removeAttribute('aria-hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function hideSiblings(container, mountNode) {
|
||||
siblings(container, mountNode, function (node) {
|
||||
return ariaHidden(true, node);
|
||||
});
|
||||
}
|
||||
|
||||
function showSiblings(container, mountNode) {
|
||||
siblings(container, mountNode, function (node) {
|
||||
return ariaHidden(false, node);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user