Shrinking

This commit is contained in:
Yorhel 2023-07-28 08:09:46 +02:00
parent b5857a7cd0
commit c9f185c6c9
4 changed files with 17 additions and 18 deletions

View file

@ -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)   This is a shallow fork of [mithril.js](https://mithril.js.org/) with some
[![License](https://img.shields.io/npm/l/mithril.svg)](https://github.com/MithrilJS/mithril.js/blob/main/LICENSE)   functionality removed to save a few bytes. In particular:
[![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)   - No routing
[![Donate at OpenCollective](https://img.shields.io/opencollective/all/mithriljs.svg?colorB=brightgreen)](https://opencollective.com/mithriljs)   - No XHR wrapper
[![Zulip, join chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://mithril.zulipchat.com/) - 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) - [What is Mithril.js?](#what-is-mithriljs)
- [Installation](#installation) - [Installation](#installation)

View file

@ -9,8 +9,7 @@ module.exports = function(render, schedule, console) {
function sync() { function sync() {
for (offset = 0; offset < subscriptions.length; offset += 2) { for (offset = 0; offset < subscriptions.length; offset += 2) {
try { render(subscriptions[offset], Vnode(subscriptions[offset + 1]), redraw) } render(subscriptions[offset], Vnode(subscriptions[offset + 1]), redraw)
catch (e) { console.error(e) }
} }
offset = -1 offset = -1
} }

View file

@ -1,7 +1,6 @@
"use strict" "use strict"
var hyperscript = require("./hyperscript") var hyperscript = require("./hyperscript")
var request = require("./request")
var mountRedraw = require("./mount-redraw") var mountRedraw = require("./mount-redraw")
var domFor = require("./render/domFor") var domFor = require("./render/domFor")
@ -11,16 +10,9 @@ m.trust = hyperscript.trust
m.fragment = hyperscript.fragment m.fragment = hyperscript.fragment
m.Fragment = "[" m.Fragment = "["
m.mount = mountRedraw.mount m.mount = mountRedraw.mount
m.route = require("./route")
m.render = require("./render") m.render = require("./render")
m.redraw = mountRedraw.redraw 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.vnode = require("./render/vnode")
m.censor = require("./util/censor")
m.domFor = domFor.domFor m.domFor = domFor.domFor
module.exports = m module.exports = m

View file

@ -699,7 +699,7 @@ module.exports = function() {
if (vnode.tag === "option" && old !== null && vnode.dom.value === "" + value) return 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 //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. // 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 */ /* eslint-enable no-implicit-coercion */
} }
vnode.dom[key] = value vnode.dom[key] = value