UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

21 lines (20 loc) 899 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isElementDisabled = void 0; /** * Checks whether an element is disabled, either via the native `disabled` DOM property (set, for * example, by `useListItemRegister` when an item's id is included in `state.nonInteractiveIds`) or * via the `aria-disabled="true"` attribute (set by consumers directly on an item, e.g. * `<Menu.Item aria-disabled>`). * * Collection items should use this check instead of testing `aria-disabled` alone so that items * disabled through either mechanism are consistently blocked from activating (click, Enter/Space, * hover-intent, etc.). */ const isElementDisabled = (element) => { if (!element) { return false; } return element.getAttribute('aria-disabled') === 'true' || element.hasAttribute('disabled'); }; exports.isElementDisabled = isElementDisabled;