Dashboard sipadu mbip
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

manageAriaHidden.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var BLACKLIST = ['template', 'script', 'style'];
  2. var isHidable = function isHidable(_ref) {
  3. var nodeType = _ref.nodeType,
  4. tagName = _ref.tagName;
  5. return nodeType === 1 && BLACKLIST.indexOf(tagName.toLowerCase()) === -1;
  6. };
  7. var siblings = function siblings(container, exclude, cb) {
  8. exclude = [].concat(exclude);
  9. [].forEach.call(container.children, function (node) {
  10. if (exclude.indexOf(node) === -1 && isHidable(node)) {
  11. cb(node);
  12. }
  13. });
  14. };
  15. export function ariaHidden(show, node) {
  16. if (!node) return;
  17. if (show) {
  18. node.setAttribute('aria-hidden', 'true');
  19. } else {
  20. node.removeAttribute('aria-hidden');
  21. }
  22. }
  23. export function hideSiblings(container, _ref2) {
  24. var root = _ref2.root,
  25. backdrop = _ref2.backdrop;
  26. siblings(container, [root, backdrop], function (node) {
  27. return ariaHidden(true, node);
  28. });
  29. }
  30. export function showSiblings(container, _ref3) {
  31. var root = _ref3.root,
  32. backdrop = _ref3.backdrop;
  33. siblings(container, [root, backdrop], function (node) {
  34. return ariaHidden(false, node);
  35. });
  36. }