How to use the dom-lib.contains function in dom-lib

To help you get started, we’ve selected a few dom-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rsuite / rsuite / src / fixtures / BaseModal.js View on Github external
focus() {
        let autoFocus = this.props.autoFocus;
        let modalContent = this.getDialogElement();
        let current = activeElement(ownerDocument(this));
        let focusInModal = current && contains(modalContent, current);

        if (modalContent && autoFocus && !focusInModal) {
            this.lastFocus = current;

            if (!modalContent.hasAttribute('tabIndex')) {
                modalContent.setAttribute('tabIndex', -1);
                new Error(false, 'The modal content node does not accept focus. ' + 'For the benefit of assistive technologies, the tabIndex of the node is being set to "-1".');
            }

            modalContent.focus();
        }
    },
github rsuite / rsuite / src / fixtures / BaseModal.js View on Github external
enforceFocus() {
        let {enforceFocus} = this.props;

        if (!enforceFocus || !this.isMounted() || !this.isTopModal()) {
            return;
        }

        let active = activeElement(ownerDocument(this));
        let modal = this.getDialogElement();

        if (modal && modal !== active && !contains(modal, active)) {
            modal.focus();
        }
    },
github rsuite / rsuite / src / utils / handleMouseOverOut.js View on Github external
export default function handleMouseOverOut(handler: Function, event: SyntheticEvent<*>) {
  let target = event.currentTarget;
  let related = event.relatedTarget || _.get(event, ['nativeEvent', 'toElement']);

  if ((!related || (related !== target)) && !contains(target, related)) {
    handler(event);
  }
}