1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.ariaHidden = ariaHidden;
|
5 | exports.hideSiblings = hideSiblings;
|
6 | exports.showSiblings = showSiblings;
|
7 | var BLACKLIST = ['template', 'script', 'style'];
|
8 |
|
9 | var isHidable = function isHidable(_ref) {
|
10 | var nodeType = _ref.nodeType,
|
11 | tagName = _ref.tagName;
|
12 | return nodeType === 1 && BLACKLIST.indexOf(tagName.toLowerCase()) === -1;
|
13 | };
|
14 |
|
15 | var 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 |
|
23 | function 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 |
|
33 | function 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 |
|
41 | function 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 |