How to use the dom-helpers/ownerDocument 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 mui-org / material-ui / src / utils / ClickAwayListener.js View on Github external
handleClickAway = event => {
    // Ignore events that have been `event.preventDefault()` marked.
    if (event.defaultPrevented) {
      return;
    }

    // IE11 support, which trigger the handleClickAway even after the unbind
    if (!this.mounted) {
      return;
    }

    const el = ReactDOM.findDOMNode(this);
    const doc = ownerDocument(el);

    if (
      doc.documentElement &&
      doc.documentElement.contains(event.target) &&
      !isDescendant(el, event.target)
    ) {
      this.props.onClickAway(event);
    }
  };
github mui-org / material-ui / src / Portal / Portal.js View on Github external
function getOwnerDocument(element) {
  return ownerDocument(ReactDOM.findDOMNode(element));
}
github jquense / react-bootstrap-modal / src / Modal.js View on Github external
_getStyles() {
    if (!canUseDOM)
      return {}

    let node = findDOMNode(this.dialog)
      , doc = ownerDocument(node)
      , scrollHt = node.scrollHeight
      , bodyIsOverflowing = isOverflowing(this.props.container || doc.body)
      , modalIsOverflowing = scrollHt > doc.documentElement.clientHeight

    return {
      dialog: {
        zIndex: getZIndex('modal'),
        paddingRight: bodyIsOverflowing && !modalIsOverflowing ? scrollbarWidth() : void 0,
        paddingLeft:  !bodyIsOverflowing && modalIsOverflowing ? scrollbarWidth() : void 0
      },
      backdrop: {
        zIndex: getZIndex('backdrop')
      }
    }
  }
github jkk / shinkgs / src / ui / common / Portal.js View on Github external
function ownerDocument2(componentOrElement2) {
  return ownerDocument(ReactDOM.findDOMNode(componentOrElement2));
}
github jquense / react-dom-lite / src / Reconciler.js View on Github external
createTextInstance(
    text: string,
    rootContainerInstance: DOMContainer,
    hostContext,
    internalInstanceHandle,
  ): Text {
    const inst = getOwnerDocument(rootContainerInstance).createTextNode(text);
    cacheHandleByInstance(inst, internalInstanceHandle);
    return inst;
  },
github react-bootstrap / react-overlays / src / utils / isOverflowing.js View on Github external
function bodyIsOverflowing(node) {
  let doc = ownerDocument(node);
  let win = isWindow(doc);

  return doc.body.clientWidth < win.innerWidth;
}
github jquense / react-dom-lite / src / Reconciler.js View on Github external
function createElement(type, props, rootContainerElement, isSvg): Element {
  const ownerDocument = getOwnerDocument(rootContainerElement);
  let domElement = isSvg
    ? ownerDocument.createElementNS('http://www.w3.org/2000/svg', type)
    : ownerDocument.createElement(type);
  return domElement;
}
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();
    }
github react-bootstrap / react-bootstrap / src / Modal.js View on Github external
updateStyle() {
    if (!canUseDOM) {
      return;
    }

    const dialogNode = this._modal.getDialogElement();
    const dialogHeight = dialogNode.scrollHeight;

    const document = ownerDocument(dialogNode);
    const bodyIsOverflowing = isOverflowing(
      ReactDOM.findDOMNode(this.props.container || document.body)
    );
    const modalIsOverflowing =
      dialogHeight > document.documentElement.clientHeight;

    this.setState({
      style: {
        paddingRight:
          bodyIsOverflowing && !modalIsOverflowing
            ? getScrollbarSize()
            : undefined,
        paddingLeft:
          !bodyIsOverflowing && modalIsOverflowing
            ? getScrollbarSize()
            : undefined