How to use the dom-helpers/query/contains function in dom-helpers

To help you get started, we’ve selected a few dom-helpers 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 deranjer / goTorrent / goTorrentWebUI / node_modules / material-ui / es / Popover / Popover.js View on Github external
getContentAnchorOffset(element) {
    const { getContentAnchorEl, anchorReference } = this.props;
    let contentAnchorOffset = 0;

    if (getContentAnchorEl && anchorReference === 'anchorEl') {
      const contentAnchorEl = getContentAnchorEl(element);

      if (contentAnchorEl && contains(element, contentAnchorEl)) {
        const scrollTop = getScrollParent(element, contentAnchorEl);
        contentAnchorOffset = contentAnchorEl.offsetTop + contentAnchorEl.clientHeight / 2 - scrollTop || 0;
      }

      // != the default value
      process.env.NODE_ENV !== "production" ? warning(this.props.anchorOrigin.vertical === 'top', ['Material-UI: you can not change the default `anchorOrigin.vertical` value ', 'when also providing the `getContentAnchorEl` property to the popover component.', 'Only use one of the two properties.', 'Set `getContentAnchorEl` to null or left `anchorOrigin.vertical` unchanged.'].join('\n')) : void 0;
    }

    return contentAnchorOffset;
  }
github poooi / poi / views / polyfills / react-bootstrap.es View on Github external
handleMouseOverOut(handler, e, relatedNative) {
    const target = e.currentTarget
    const related = e.relatedTarget || e.nativeEvent[relatedNative]

    if ((!related || related !== target) && !contains(target, related)) {
      handler(target, true)
    }
  }
github kata-ai / wicara / packages / tooltip / src / components / TooltipTarget.tsx View on Github external
handleMouseOverOut(handler: any, e: any, relatedNative: string) {
    const target = e.currentTarget;
    const related = e.relatedTarget || e.nativeEvent[relatedNative];

    if ((!related || related !== target) && !contains(target, related)) {
      handler(e);
    }
  }
github mui-org / material-ui / src / Modal / Modal.js View on Github external
handleFocusListener = () => {
    if (!this.mounted || !this.props.modalManager.isTopModal(this)) {
      return;
    }

    const currentFocus = activeElement(ownerDocument(ReactDOM.findDOMNode(this)));
    const modalContent = this.modal && this.modal.lastChild;

    if (modalContent && modalContent !== currentFocus && !contains(modalContent, currentFocus)) {
      modalContent.focus();
    }
  };
github OHIF / react-viewerbase / src / components / overlayTrigger / OverlayTrigger.js View on Github external
handleMouseOverOut(handler, e, relatedNative) {
    const target = e.currentTarget;
    const related = e.relatedTarget || e.nativeEvent[relatedNative];

    if ((!related || related !== target) && !contains(target, related)) {
      handler(e);
    }
  }
github zhbhun / WebpackStudyDemo / 7-advanced / 7.3-buil-performance / src / Dropdown.js View on Github external
componentWillUpdate(nextProps) {
    if (!nextProps.open && this.props.open) {
      this._focusInDropdown = contains(
        ReactDOM.findDOMNode(this.menu),
        activeElement(document)
      );
    }
  }
github forestturner / PokerHandRangeCalc / node_modules / react-bootstrap / es / Dropdown.js View on Github external
Dropdown.prototype.componentWillUpdate = function componentWillUpdate(nextProps) {
    if (!nextProps.open && this.props.open) {
      this._focusInDropdown = contains(ReactDOM.findDOMNode(this.menu), activeElement(document));
    }
  };
github trendmicro-frontend / react-dropdown / src / Dropdown.jsx View on Github external
getSnapshotBeforeUpdate(prevProps, prevState) {
        if (!this.props.open && prevProps.open) {
            const focusInDropdown = this.menu && contains(ReactDOM.findDOMNode(this.menu), activeElement(document));
            return focusInDropdown;
        }

        return null;
    }
github mui-org / material-ui / src / Modal / Modal.spec.js View on Github external
.instance()
        .getMountNode();
      const container = document.getElementById('container');
      const heading = document.getElementById('heading');

      if (!container || !heading) {
        throw new Error('missing element');
      }

      assert.strictEqual(
        container.tagName.toLowerCase(),
        'div',
        'should have the element in the DOM',
      );
      assert.strictEqual(heading.tagName.toLowerCase(), 'h1', 'should have the element in the DOM');
      assert.strictEqual(contains(portalLayer, container), true, 'should be in the portal');
      assert.strictEqual(contains(portalLayer, heading), true, 'should be in the portal');

      const container2 = document.getElementById('container');

      if (!container2) {
        throw new Error('missing container');
      }

      assert.strictEqual(
        container2.getAttribute('role'),
        'document',
        'should add the document role',
      );
      assert.strictEqual(container2.getAttribute('tabindex'), '-1', 'should add a -1 tab-index');
    });
  });
github mui-org / material-ui / src / Modal / Modal.js View on Github external
focus() {
    const currentFocus = activeElement(ownerDocument(ReactDOM.findDOMNode(this)));
    const modalContent = this.modal && this.modal.lastChild;
    const focusInModal = currentFocus && contains(modalContent, currentFocus);

    if (modalContent && !focusInModal) {
      if (!modalContent.hasAttribute('tabIndex')) {
        modalContent.setAttribute('tabIndex', -1);
        warning(
          false,
          'Material-UI: 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();
    }
  }