Skip to content

Commit

Permalink
devtools: prefer globalThis over window if available
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed May 29, 2024
1 parent a263130 commit eb3fb62
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions devtools/src/devtools.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { options, Fragment, Component } from 'preact';
import { Component, Fragment, options } from 'preact';

export function initDevTools() {
if (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {
window.__PREACT_DEVTOOLS__.attachPreact('10.22.0', options, {
const globalVar =
typeof globalThis !== 'undefined'
? globalThis
: typeof window !== 'undefined'
? window
: undefined;

if (
globalVar !== null &&
globalVar !== undefined &&
globalVar.__PREACT_DEVTOOLS__
) {
globalVar.__PREACT_DEVTOOLS__.attachPreact('10.22.0', options, {
Fragment,
Component
});
Expand Down

0 comments on commit eb3fb62

Please sign in to comment.