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

Make GlobalRegistrator registered info public #1670

Closed
infodusha opened this issue Jan 7, 2025 · 2 comments · Fixed by #1674
Closed

Make GlobalRegistrator registered info public #1670

infodusha opened this issue Jan 7, 2025 · 2 comments · Fixed by #1674
Assignees
Labels
easy fix enhancement New feature or request

Comments

@infodusha
Copy link

Is your feature request related to a problem? Please describe.
I want to know if globals have already been applied

if (!GlobalRegistrator.registered) {
  GlobalRegistrator.register({
    settings: {
      disableJavaScriptEvaluation: true,
      disableJavaScriptFileLoading: true,
      disableComputedStyleRendering: true,
    },
  });
}

Describe the solution you'd like
I see it as a static getter isRegistered on GlobalRegistrator class but will be glad to see any solution to my problem.

Describe alternatives you've considered

  1. I could check if window is already defined but that could be a different window, other that from happy-dom
    Also AFAIK typeof window === undefined check could be eliminated as a dead code with some bundlers.

  2. The other alternative is to check .registered with @ts-ignore, but that is a code smell.

@infodusha infodusha added the enhancement New feature or request label Jan 7, 2025
@capricorn86
Copy link
Owner

@infodusha sounds like a good idea and a an easy fix 🙂

@capricorn86
Copy link
Owner

Support for this is available in v16.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy fix enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants