From 045e4f720a1d8f6ed7e7d6b73bc91aacb660ac56 Mon Sep 17 00:00:00 2001 From: Isiah Meadows Date: Wed, 14 Oct 2020 03:12:47 -0700 Subject: [PATCH] Allow Mithril to be loaded in non-browser environments without modification (#2633) --- docs/changelog.md | 1 + mount-redraw.js | 2 +- render.js | 2 +- request.js | 2 +- route.js | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 314888e5..bbea1913 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -36,6 +36,7 @@ PSA: changes to [`mithril/stream`](stream.md) are now specified in this changelo - Fix issue where new redraw handlers weren't copied over on update. ([#2578](https://github.com/MithrilJS/mithril.js/pull/2578) [@isiahmeadows](https://github.com/isiahmeadows)) - Make changes to file inputs gracefully handled, and don't break if the current value and old value mismatch (and the new value isn't empty), but instead just log an error. ([#2578](https://github.com/MithrilJS/mithril.js/pull/2578) [@isiahmeadows](https://github.com/isiahmeadows)) - This mainly exists just to kick the can down the road - this is the only case I'm aware of where the DOM itself would be responsible for throwing an error. A proper fix to the greater issue of error handling is much more complex, and I'd rather not block users any longer over this one specific issue. +- Allow Mithril to be loaded in non-browser environments without modification. ([#2633](https://github.com/MithrilJS/mithril.js/pull/2633) [@isiahmeadows](https://github.com/isiahmeadows)) Important note: if you were using any of these undocumented tools, they are no longer available as of this release. This is not considered a breaking change as they were written for internal usage and as of v2 are all 100% unsupported in userland. diff --git a/mount-redraw.js b/mount-redraw.js index 8cd149ec..bb83aede 100644 --- a/mount-redraw.js +++ b/mount-redraw.js @@ -2,4 +2,4 @@ var render = require("./render") -module.exports = require("./api/mount-redraw")(render, requestAnimationFrame, console) +module.exports = require("./api/mount-redraw")(render, typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : null, typeof console !== "undefined" ? console : null) diff --git a/render.js b/render.js index a6f8ce8d..042d7812 100644 --- a/render.js +++ b/render.js @@ -1,3 +1,3 @@ "use strict" -module.exports = require("./render/render")(window) +module.exports = require("./render/render")(typeof window !== "undefined" ? window : null) diff --git a/request.js b/request.js index 06fb2bbd..49a3968c 100644 --- a/request.js +++ b/request.js @@ -3,4 +3,4 @@ var PromisePolyfill = require("./promise/promise") var mountRedraw = require("./mount-redraw") -module.exports = require("./request/request")(window, PromisePolyfill, mountRedraw.redraw) +module.exports = require("./request/request")(typeof window !== "undefined" ? window : null, PromisePolyfill, mountRedraw.redraw) diff --git a/route.js b/route.js index 9cf121e2..6d9acd68 100644 --- a/route.js +++ b/route.js @@ -2,4 +2,4 @@ var mountRedraw = require("./mount-redraw") -module.exports = require("./api/router")(window, mountRedraw) +module.exports = require("./api/router")(typeof window !== "undefined" ? window : null, mountRedraw)