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

Allow Mithril to be loaded in non-browser environments without modification #2633

Merged
merged 1 commit into from
Oct 14, 2020

Conversation

dead-claudia
Copy link
Member

@dead-claudia dead-claudia commented Oct 7, 2020

Description

Recast the global reads to all be guarded with typeof, so that if they aren't defined, they're just null.

Note that this does not involve documentation changes, as that's going to require a lot more effort and is best left as a follow-up. (Our support for this is undocumented anyways, and the relevant docs are for hooking it up with JSDOM. This only really matters in practice if you're using mithril-node-render.)

Motivation and Context

This has been a fairly common gotcha, and I'd like to actually fix it rather than repeatedly tell users how to work around it in about 2-3 different ways (depending on how they test their app). This in effect moves that workaround into core, but without polluting the global scope like #2613.

Closes #2613

How Has This Been Tested?

Ran require("./.") in the package root from a fresh Node REPL and no errors occurred.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated docs/changelog.md

@leontrolski
Copy link

I replaced this line
With "mithril": "git+https://github.com/isiahmeadows/mithril.js.git#bugfix", ran rm -rf node_modules; npm install; npm test and it worked like a charm. 👍

Copy link
Member

@orbitbot orbitbot left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Can verify like @leontrolski that listed repro steps work as expected, but didn't do any wider verification as of right now wrt. actual functionality.

OT, re: PR branching, it might be a bit more straightforward to use individual names for each PR, but it's no biggie. Haven't really come to terms with git worktree across multiple upstream repositories yet, but that issue is mainly on this end 😉

@dead-claudia
Copy link
Member Author

@orbitbot Regarding the branch name, I just lazied it. Normally, I'm more descriptive than this (and I prefer separate branches for each individual feature + fix), but yeah, I was lazy this time around and didn't feel like creating a whole new branch.

@dead-claudia dead-claudia merged commit 045e4f7 into MithrilJS:next Oct 14, 2020
@dead-claudia dead-claudia deleted the bugfix branch October 14, 2020 10:12
@JAForbes JAForbes mentioned this pull request Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

3 participants