UNPKG

1.18 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.ariaHidden = ariaHidden;
5exports.hideSiblings = hideSiblings;
6exports.showSiblings = showSiblings;
7var BLACKLIST = ['template', 'script', 'style'];
8
9var isHidable = function isHidable(_ref) {
10 var nodeType = _ref.nodeType,
11 tagName = _ref.tagName;
12 return nodeType === 1 && BLACKLIST.indexOf(tagName.toLowerCase()) === -1;
13};
14
15var siblings = function siblings(container, exclude, cb) {
16 [].forEach.call(container.children, function (node) {
17 if (exclude.indexOf(node) === -1 && isHidable(node)) {
18 cb(node);
19 }
20 });
21};
22
23function ariaHidden(hide, node) {
24 if (!node) return;
25
26 if (hide) {
27 node.setAttribute('aria-hidden', 'true');
28 } else {
29 node.removeAttribute('aria-hidden');
30 }
31}
32
33function hideSiblings(container, _ref2) {
34 var dialog = _ref2.dialog,
35 backdrop = _ref2.backdrop;
36 siblings(container, [dialog, backdrop], function (node) {
37 return ariaHidden(true, node);
38 });
39}
40
41function showSiblings(container, _ref3) {
42 var dialog = _ref3.dialog,
43 backdrop = _ref3.backdrop;
44 siblings(container, [dialog, backdrop], function (node) {
45 return ariaHidden(false, node);
46 });
47}
\No newline at end of file