Skip to content

Commit

Permalink
docs: replace window with global this object
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Dec 1, 2024
1 parent 277977b commit eed1b80
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/components/Head.astro
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ let isProduction = import.meta.env.PROD
} else if (localStorage.getItem('theme') === 'dark') {
theme = 'dark'
} else {
let systemTheme = window.matchMedia('(prefers-color-scheme: dark)')
let systemTheme = globalThis.matchMedia('(prefers-color-scheme: dark)')
.matches
? 'dark'
: 'light'
Expand Down
2 changes: 1 addition & 1 deletion docs/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let { border = false } = Astro.props
let header = document.querySelector('.header')!

document.addEventListener('scroll', () => {
let scrollY = window.scrollY
let { scrollY } = globalThis

if (!header.classList.contains('border')) {
if (scrollY > 24) {
Expand Down
2 changes: 1 addition & 1 deletion docs/components/TableOfContents/TableOfContents.astro
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let toc = buildToc(headings)
let initToc = () => {
let observer = new IntersectionObserver(
entries => {
if (window.scrollY === 0) {
if (globalThis.scrollY === 0) {
let firstTocItem = document.querySelector('.table-of-content a')
let previouslyActivatedItem = document.querySelector('.active')
previouslyActivatedItem?.classList.remove('active')
Expand Down

0 comments on commit eed1b80

Please sign in to comment.