12345678910111213141516171819202122232425262728293031323334353637383940 |
- 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, exclude, cb) {
- exclude = [].concat(exclude);
- [].forEach.call(container.children, function (node) {
- if (exclude.indexOf(node) === -1 && isHidable(node)) {
- cb(node);
- }
- });
- };
-
- export function ariaHidden(show, node) {
- if (!node) return;
-
- if (show) {
- node.setAttribute('aria-hidden', 'true');
- } else {
- node.removeAttribute('aria-hidden');
- }
- }
- export function hideSiblings(container, _ref2) {
- var root = _ref2.root,
- backdrop = _ref2.backdrop;
- siblings(container, [root, backdrop], function (node) {
- return ariaHidden(true, node);
- });
- }
- export function showSiblings(container, _ref3) {
- var root = _ref3.root,
- backdrop = _ref3.backdrop;
- siblings(container, [root, backdrop], function (node) {
- return ariaHidden(false, node);
- });
- }
|