landmark-has-body-context-matches.js 481 B

12345678910111213
  1. import { findUpVirtual } from '../commons/dom';
  2. function landmarkHasBodyContextMatches(node, virtualNode) {
  3. const nativeScopeFilter = 'article, aside, main, nav, section';
  4. // Filter elements that, within certain contexts, don't map their role.
  5. // e.g. a <header> inside a <main> is not a banner, but in the <body> context it is
  6. return (
  7. node.hasAttribute('role') || !findUpVirtual(virtualNode, nativeScopeFilter)
  8. );
  9. }
  10. export default landmarkHasBodyContextMatches;