UNPKG

@qualweb/util

Version:
17 lines (16 loc) 691 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function landmarkIsTopLevel(element) { const landmarks = ['application', 'banner', 'contentinfo', 'main', 'complementary', 'form', 'navigation', 'region']; let parent = element.getElementParent(); const nodeRole = window.AccessibilityUtils.getElementRole(element); while (parent) { const role = window.AccessibilityUtils.getElementRole(parent); if (role && landmarks.includes(role) && !(role === 'main' && nodeRole === 'complementary')) { return false; } parent = parent.getElementParent(); } return true; } exports.default = landmarkIsTopLevel;