From c9f185c6c9748d3836bc480f158f1a9b7800e234 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Fri, 28 Jul 2023 08:09:46 +0200 Subject: [PATCH] Shrinking --- README.md | 22 +++++++++++++++------- api/mount-redraw.js | 3 +-- index.js | 8 -------- render/render.js | 2 +- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 32b8d20e..8277a4cd 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,19 @@ -# Mithril.js +# VNDB Fork of Mithril.js -[![npm Version](https://img.shields.io/npm/v/mithril.svg)](https://www.npmjs.com/package/mithril)   -[![License](https://img.shields.io/npm/l/mithril.svg)](https://github.com/MithrilJS/mithril.js/blob/main/LICENSE)   -[![npm Downloads](https://img.shields.io/npm/dm/mithril.svg)](https://www.npmjs.com/package/mithril)   -[![Build Status](https://img.shields.io/github/actions/workflow/status/MithrilJS/mithril.js/.github%2Fworkflows%2Ftest-main-push.yml)](https://www.npmjs.com/package/mithril)   -[![Donate at OpenCollective](https://img.shields.io/opencollective/all/mithriljs.svg?colorB=brightgreen)](https://opencollective.com/mithriljs)   -[![Zulip, join chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://mithril.zulipchat.com/) +This is a shallow fork of [mithril.js](https://mithril.js.org/) with some +functionality removed to save a few bytes. In particular: + +- No routing +- No XHR wrapper +- No URL helper utilities +- 'throw' errors instead of console.error() (nothing to do with size, just makes it easier to capture errors) + +There's room for further optimization, but that easily runs into diminishing +returns. This'll do for now. + +(Original README below) + +# Mithril.js - [What is Mithril.js?](#what-is-mithriljs) - [Installation](#installation) diff --git a/api/mount-redraw.js b/api/mount-redraw.js index 4f7d0f60..7de2f5a8 100644 --- a/api/mount-redraw.js +++ b/api/mount-redraw.js @@ -9,8 +9,7 @@ module.exports = function(render, schedule, console) { function sync() { for (offset = 0; offset < subscriptions.length; offset += 2) { - try { render(subscriptions[offset], Vnode(subscriptions[offset + 1]), redraw) } - catch (e) { console.error(e) } + render(subscriptions[offset], Vnode(subscriptions[offset + 1]), redraw) } offset = -1 } diff --git a/index.js b/index.js index b6ca3406..5dac7b58 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ "use strict" var hyperscript = require("./hyperscript") -var request = require("./request") var mountRedraw = require("./mount-redraw") var domFor = require("./render/domFor") @@ -11,16 +10,9 @@ m.trust = hyperscript.trust m.fragment = hyperscript.fragment m.Fragment = "[" m.mount = mountRedraw.mount -m.route = require("./route") m.render = require("./render") m.redraw = mountRedraw.redraw -m.request = request.request -m.parseQueryString = require("./querystring/parse") -m.buildQueryString = require("./querystring/build") -m.parsePathname = require("./pathname/parse") -m.buildPathname = require("./pathname/build") m.vnode = require("./render/vnode") -m.censor = require("./util/censor") m.domFor = domFor.domFor module.exports = m diff --git a/render/render.js b/render/render.js index a4124432..fa5e8f9b 100644 --- a/render/render.js +++ b/render/render.js @@ -699,7 +699,7 @@ module.exports = function() { if (vnode.tag === "option" && old !== null && vnode.dom.value === "" + value) return //setting input[type=file][value] to different value is an error if it's non-empty // Not ideal, but it at least works around the most common source of uncaught exceptions for now. - if (isFileInput && "" + value !== "") { console.error("`value` is read-only on file inputs!"); return } + if (isFileInput && "" + value !== "") { throw new Error("`value` is read-only on file inputs!"); return } /* eslint-enable no-implicit-coercion */ } vnode.dom[key] = value