Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Add fallback to ownerWindow #10978

Merged
merged 2 commits into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ButtonBase/ButtonBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import keycode from 'keycode';
import ownerWindow from 'dom-helpers/ownerWindow';
import { polyfill } from 'react-lifecycles-compat';
import ownerWindow from '../utils/ownerWindow';
import withStyles from '../styles/withStyles';
import { listenForFocusKeys, detectKeyboardFocus } from '../utils/keyboardFocus';
import TouchRipple from './TouchRipple';
Expand Down
2 changes: 1 addition & 1 deletion src/Modal/isOverflowing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isWindow from 'dom-helpers/query/isWindow';
import ownerDocument from 'dom-helpers/ownerDocument';
import ownerWindow from 'dom-helpers/ownerWindow';
import ownerWindow from '../utils/ownerWindow';

export function isBody(node) {
return node && node.tagName.toLowerCase() === 'body';
Expand Down
2 changes: 1 addition & 1 deletion src/Popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import ReactDOM from 'react-dom';
import warning from 'warning';
import contains from 'dom-helpers/query/contains';
import ownerDocument from 'dom-helpers/ownerDocument';
import ownerWindow from 'dom-helpers/ownerWindow';
import debounce from 'lodash/debounce';
import EventListener from 'react-event-listener';
import ownerWindow from '../utils/ownerWindow';
import withStyles from '../styles/withStyles';
import Modal from '../Modal';
import Grow from '../transitions/Grow';
Expand Down
2 changes: 1 addition & 1 deletion src/transitions/Slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import ReactDOM from 'react-dom';
import EventListener from 'react-event-listener';
import debounce from 'lodash/debounce';
import Transition from 'react-transition-group/Transition';
import ownerWindow from 'dom-helpers/ownerWindow';
import { polyfill } from 'react-lifecycles-compat';
import ownerWindow from '../utils/ownerWindow';
import withTheme from '../styles/withTheme';
import { duration } from '../styles/transitions';
import { reflow, getTransitionProps } from './utils';
Expand Down
1 change: 1 addition & 0 deletions src/utils/ownerWindow.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function ownerWindow(node: Node, fallback?: Window): Window;
10 changes: 10 additions & 0 deletions src/utils/ownerWindow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @flow

import ownerDocument from 'dom-helpers/ownerDocument';

const ownerWindow = (node: Node, fallback: window = window) => {
const doc: Document = ownerDocument(node);
return doc.defaultView || doc.parentView || fallback;
};

export default ownerWindow;