Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(mixed): avoid usages of global document and window #1970

Merged
merged 3 commits into from
Sep 25, 2019

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Sep 25, 2019

Fixes #1964.

This PR removes remaining usages of document and window globals in components. Also forces ESLint to catch such issues.

@codecov
Copy link

codecov bot commented Sep 25, 2019

Codecov Report

Merging #1970 into master will increase coverage by 0.01%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1970      +/-   ##
=========================================
+ Coverage   70.29%   70.3%   +0.01%     
=========================================
  Files         894     894              
  Lines        7901    7905       +4     
  Branches     2313    2291      -22     
=========================================
+ Hits         5554    5558       +4     
  Misses       2334    2334              
  Partials       13      13
Impacted Files Coverage Δ
...ckages/react/src/lib/positioner/getScrollParent.ts 89.47% <ø> (ø) ⬆️
.../src/lib/accessibility/FocusZone/focusUtilities.ts 87.75% <ø> (ø) ⬆️
packages/react/src/lib/debug/index.ts 100% <ø> (ø) ⬆️
packages/react/src/lib/felaRenderer.tsx 76.92% <ø> (ø) ⬆️
packages/react/src/lib/debug/debugApi.ts 39.02% <ø> (ø) ⬆️
packages/react/src/lib/isBrowser.tsx 100% <ø> (ø) ⬆️
packages/react/src/lib/doesNodeContainClick.tsx 100% <100%> (ø) ⬆️
packages/react/src/lib/mergeProviderContexts.ts 100% <100%> (ø) ⬆️
packages/react/src/components/Loader/Loader.tsx 100% <100%> (ø) ⬆️
packages/react/src/lib/fontSizeUtility.ts 93.33% <100%> (ø) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88d17b1...c2bf935. Read the comment docs.

},
"rules": {
"no-undef": "error"
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary solution until we will merge #1963.

"files": "src/**/*.{ts,tsx}",
"globals": {
"document": "off",
"window": "off"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's reasonable to disable only document and window globals as they are context dependent.

@@ -273,7 +273,9 @@ export default class Popup extends AutoControlledComponent<PopupProps, PopupStat
const lastContentRef = getRefs().pop()
const isLastOpenedPopup: boolean =
lastContentRef && lastContentRef.current === this.popupDomElement
const bodyHasFocus: boolean = document.activeElement === document.body

const activeDocument = this.props.mountDocument || this.context.target
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to consider remove mountDocument prop from Popup at all.

}
this.animationFrameId = window.requestAnimationFrame(() => {

this.animationFrameId = requestAnimationFrame(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with @miroslavstastny, there are no reasons to use it from window

@layershifter layershifter merged commit c7af11c into master Sep 25, 2019
@layershifter layershifter deleted the fix/document-usage-in-components branch September 25, 2019 13:58
layershifter added a commit that referenced this pull request Sep 26, 2019
layershifter added a commit that referenced this pull request Oct 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🧰 fix Introduces fix for broken behavior. 🚀 ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove usage of global document and window from components
2 participants