Mithril.js Versions Save

A JavaScript Framework for Building Brilliant Applications

v2.2.3

1 year ago

Release v2.2.2

  • #2773

Changelog

Patch Changes

Use markdown for the README badges (@pygy)

Use markdown for the README badges.

v2.2.2

1 year ago

Release v2.2.2

  • #2773

Changelog

Patch Changes

Use markdown for the README badges (@pygy)

Use markdown for the README badges.

v2.2.1

1 year ago

Release v2.2.1

  • #2771

Changelog

Patch Changes

Move the chat to Zulip (@pygy)

This updates the documentation to link to the new Zulip chat room.

v2.2.0

1 year ago

Release v2.2.0

  • #2769
  • #2752
  • #2768
  • #2578
  • #2722
  • #2316
  • #2750
  • #2711
  • #2743
  • #2670
  • #2695
  • #2641
  • #2655
  • #2537
  • #2646
  • #2633
  • #2594
  • #2603
  • #2539
  • #2536
  • #2405
  • #2744
  • #2765
  • #2760
  • #2758
  • #2751
  • #2757
  • #2748
  • #2745
  • #2620
  • #2644
  • #2649
  • #1767
  • #2718
  • #2693
  • #2741
  • #2651
  • #2721
  • #2353
  • #2206
  • #2648
  • #2672
  • #2717
  • #2348
  • #2698
  • #2696
  • #2684
  • #2680
  • #2679
  • #2673
  • #2674
  • #2657
  • #2639
  • #2487
  • #2585
  • #2630
  • #2629
  • #2628
  • #2627
  • #2608
  • #2605
  • #2593
  • #2582
  • #2576
  • #2573
  • #2567
  • #2561
  • #2553
  • #2540
  • #2538
  • #2522
  • #2513

Changelog

Minor Changes

m.censor: work around a bunder bug (@kfule)

The internal bundler sometimes mangles the words in RegExp literals incorrectly. Please see below.

Warn about reusing mutated attrs object - fixes #2719 (@StephanHoyer)

Send URLSearchParams as request body without extra configuration (@Coteh)

This PR fixes an oddity I noticed in the way m.request handles URLSearchParams object. It now handles it in the same sort of way XHR and Fetch do it.

Add params: to m.route.Link, fix docs (@dead-claudia)

Add params: to m.route.Link. Minor fix to docs to reflect reality with m.route.Link's disabled: attribute.

Allow Mithril to be loaded in non-browser environments without modification (@dead-claudia)

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

Add a m.Fragment = "[" utility for JSX users. (@dead-claudia)

The title says it all, and the diff's obvious. Resolves https://github.com/MithrilJS/mithril.js/issues/2640 and probably others.

Patch Changes

Enable --minimize-semver-change for pr-release (@JAForbes)

Minimizes semver changes on release to the minimum required version bump to satisfy major/minor/patch semver ranges. Minimizes the semver change so that.

An attempt at better demonstrating m.route.Link with less text. Fixes #2767.

Runtime-deprecate ospec, change change-log to changelog, fix a few assorted bugs (@dead-claudia)

This PR is in two parts: 1. Revise the build system and some of the local dev setup. Fully split ospec from the repo, and add it as a dependency.

Add meta description to docs (@StephanHoyer)

rework of #2149. added a meta description parser and meta descriptions to all docs pages. because google. built the docs, inspected the output manually.

Fixed badges, consistent naming of Mithril.js (@tbreuss)

use consistent naming of Mithril.js. fix badges in README. Fixes issue #2749.

Catch malformed URI Components (@jdiderik)

Fix for error thrown when a value contains non-valid / malformed URI Component. Example: test=%c5%a1%e8ZM%80%82H. will throw "URI malformed".

Correctly handle invalid escapes in routes based on 0a5ead31c9fbd7b153c521c7f9d3df7bf826ce6c (@StephanHoyer)

fixes #2061. @dead-claudia I just redid your change but slightly different in order to handle a mix of wrong and right encodings properly.

Standardise vnode text representation (@barneycarroll)

This addresses the crucial feature of #2669: text is always represented as virtual text nodes, never as a vnode.text.

Issue 2624 no content 204 parse (@Evoke-PHP)

Added guard so that JSON.parse does not fail on IE11 with no content empty string being parsed. Fixes https://github.com/MithrilJS/mithril.js/issues/2624.

[m.request] work around a bundler bug, fix #2647 (@pygy)

The bundler mangles identifier-like strings within RegExps, this works around the problem by not using such RegExps.

Reject request on XHR timeout (@kevinfiol)

Derived from PR #2581. Allows requests to properly reject on event of a timeout.

Remove extra isLifecycleMethod call from removeAttr (@ZeikJT)

Removing an extra isLifecycleMethod in the removeAttr method, it isn't needed since it's already checked on the previous line.

Fix #2601 (@dead-claudia)

Fix issue where ending a stream in the middle of a stream callback would result in erroneous parent stream state for the rest of that emit. Fixes #2601.

Add streams to releases again, include minified bundle, drop internal stuff from npm (@dead-claudia)

Add stream/stream.js to releases again. Add stream/stream.min.js now that the process is remotely sane now.

Make errors and their messages more accurate and helpful (@dead-claudia)

I updated error messages to be much more helpful.

Fix assertion descriptions (@soulofmischief)

I moved the return statement to the end of define() so that it returns even if the comparison fails.

Fix branch target (@dead-claudia)

https://github.com/MithrilJS/mithril.js/runs/6199543939?check_suite_focus=true.

Automate mithril's release workflow (@JAForbes)

Automated releases, pre-releases, (code) rollbacks and recovery, npm publishing, change log management just by using normal github flow.

rework jsx docs (@StephanHoyer)

Add Simple Application Flems Supporting v2.0.4 and up (@tbreuss)

Added Flems for Simple Application supporting v2.0.4 of Mithril.js. Fixes Issue #2710.

Make example work with webpack v5.69.1 (@StephanHoyer)

fixes #2634.

2604: correct and move text about statements in view method (@kevinfiol)

Addresses #2604.

Fix lint errors (@StephanHoyer)

WIP: Update modularisation details in Installation docs (@orbitbot)

added link to flems.io as an easier way to just try out the framework. -. Documentation has grown a bit stale.

Added power support for the travis.yml file with ppc64le (@sreekanth370)

Added power support for the travis.yml file with ppc64le. This is part of the Ubuntu distribution for ppc64le.

Updated babel/webpack docs to work with latest versions (@pereriksson)

As a developer I tried setting up Mithril with Babel and Webpack but failed because of a variety of errors.

[docs] route redirection using the history API (@pygy)

This is an attempt at fixing #1759, but there may be more to be added. Feedback welcome. ping @dontwork.

Bump path-parse from 1.0.6 to 1.0.7 (@dependabot[bot])

Bumps path-parse from 1.0.6 to 1.0.7. Commits. See full diff in compare view.

Bump glob-parent from 5.1.0 to 5.1.2 (@dependabot[bot])

Bumps glob-parent from 5.1.0 to 5.1.2. Release notes. Sourced from glob-parent's releases. v5.1.2. Bug Fixes.

Bump ajv from 6.10.2 to 6.12.6 (@dependabot[bot])

Bumps ajv from 6.10.2 to 6.12.6. Release notes. Sourced from ajv's releases. v6.12.6. Fix performance issue of "url" format.

Update standalone usage (@ghost)

Avoid double encoding of function signatures - fixes #2720 (@StephanHoyer)

Show previous versions (@mike-ward)

Add Dropdown that shows links to archived versions of the documentation.

docs: improve m.request return value description (@GAumala)

In the m.request return value description, add a line informing that error status codes cause the promise to reject.

A note on JSX events (@pereriksson)

Naming JSX events according to their documentation produces unexpected results with incorrectly named events when using JSX with Mithril.

Document route resolution cancellation, fixes #1759 (@barneycarroll)

Also fixes a broken internal link.

Bump marked from 0.7.0 to 4.0.10 (@dependabot[bot])

Bumps marked from 0.7.0 to 4.0.10. Release notes. Sourced from marked's releases. v4.0.10. 4.0.10 (2022-01-13). Bug Fixes.

Flems in docs (#2348) [skip ci] (@porsager)

Added flems instead of the current codepen samples.

Content was moved some time ago and linked section no longer exists.

Cavemansspa patch 1 (@cavemansspa)

Documentation update.

Bump hosted-git-info from 2.8.4 to 2.8.9 (@dependabot[bot])

Bumps hosted-git-info from 2.8.4 to 2.8.9. Changelog. Sourced from hosted-git-info's changelog. 2.8.9 (2021-04-07).

Bump lodash from 4.17.20 to 4.17.21 (@dependabot[bot])

Bumps lodash from 4.17.20 to 4.17.21. Commits. f299b52 Bump to v4.17.21.

Bump handlebars from 4.7.6 to 4.7.7 (@dependabot[bot])

Bumps handlebars from 4.7.6 to 4.7.7. Changelog. Sourced from handlebars's changelog. v4.7.7 - February 15th, 2021.

Remove unreachable keyed node logic, fixes #2597 (@barneycarroll)

Delete test-utils/README.md (@dead-claudia)

We don't expose this publicly anymore, so there's literally no justification for this file's existence.

simple-application.md: consistent use of type=submit (@danbst)

When following tutorial and typing everything in, I was confused that Save button didn't work.

Fix inconsistent capitalizations of "JavaScript" (@mtsknn)

"Javascript"/"javascript" → "JavaScript". Fixes #2398, or at least I can't find any more incorrect capitalizations.

fix some typos (@osban)

Found some typos. Mainly unescaped | in tables, but also a few other irregularities. Not all problems are visible in the website docs.

Replace mocha by ospec in testing page (@gamtiq)

Fixed a typo in testing doc page. Currently there is reference to mocha in the page whereas opsec is used.

Bump acorn from 7.1.0 to 7.4.0 (@dependabot[bot])

Bumps acorn from 7.1.0 to 7.4.0. Commits. 54efb62 Mark version 7.4.0.

Bump handlebars from 4.4.2 to 4.7.6 (@dependabot[bot])

Bumps handlebars from 4.4.2 to 4.7.6. Changelog. Sourced from handlebars's changelog. v4.7.6 - April 3rd, 2020.

Bump lodash from 4.17.15 to 4.17.20 (@dependabot[bot])

Bumps lodash from 4.17.15 to 4.17.20. Commits. ded9bc6 Bump to v4.17.20. 63150ef Documentation fixes.

Bump minimist from 1.2.0 to 1.2.3 (@dependabot[bot])

Bumps minimist from 1.2.0 to 1.2.3. Commits. 6457d74 1.2.3. 38a4d1c even more aggressive checks for protocol pollution.

Update installation.md (@purefan)

Offer to install mithril as a webpack plugin. Just makes my life easier by not having to include mithril in every one of my js files.

replace slave label with replica (@stephanos)

One of the example is using the antiquated word "slave" for a database replica. I updated the language and tested the change.

ES6 and m.trust docs patch (@kczx3)

While reading through some of the documentation I saw some issues with both the ES6 and m.trust pages.

docs: Fix simple typo, subsequece -> subsequence (@timgates42)

There is a small typo in mithril.js, render/render.js. Should read subsequence rather than subsequece.

Change the link to point to ospec docs in github. ospec link went to mochajs. issue 2575. N/A. N/A. N/A.

updated to the Vimeo showcase (@CreaturesInUnitards)

The scrimba version of Mithril 0-60 was built on their beta platform, and doesn't really even work anymore.

adding more community examples (@boazblake)

Exclude archive of previous docs (@cztomsik)

update .npmignore so that archives are not included in the resulting package. space/bandwidth savings. fix #2552.

Pimp the docs linter (and assorted changes) (@pygy)

Add an optional cache for faster runs. Add a final report. Don't return anything from exec(). Cover more files. Look for a "--cache" option.

Recast key docs to be much clearer and more accurate (@dead-claudia)

Recast key docs to be much clearer and more accurate, including a few Flems examples to help intuitively explain things.

Add m.censor, adjust m.route.Link to use it (@dead-claudia)

Add m.censor. Adjust m.route.Link to use it. Restructure a few things for better code reuse. Fixes #2472.

Update fetch() browser support in docs (@qgustavor)

As Can I use shows fetch() supported since Safari 10.1 and iOS Safari 10.3.

docs: Add release dates to all change-log files (@maranomynet)

I'd like to introduce release dates to the change log files. Release dates are human-friendly and add a bit of historical perspective to change-log files.

v1.1.7

4 years ago

Ordinarily, I would not have released this, but it includes a backport of a security fix from v2.0.3. If you're stuck on v1.x, you should really update to this ASAP.

Bug fixes

v2.0.4

4 years ago

v2.0.3

4 years ago
  • Ensure vnodes are removed correctly in the face of onbeforeremove resolving after new nodes are added (#2492 @isiahmeadows)
  • Fix prototype pollution vulnerability in m.parseQueryString (#2494 @isiahmeadows)

v2.0.2 was skipped as it had a critical flaw and was immediately unpublished.

v2.0.1

4 years ago

This is really what v2.0.0 was supposed to be, but the npm upload got botched the first time around.

Breaking changes

  • API: Component vnode children are not normalized into vnodes on ingestion; normalization only happens if and when they are ingested by the view (#2155 (thanks to @magikstm for related optimization #2064))
  • API: m.redraw() is always asynchronous (#1592)
  • API: m.mount() will only render its own root when called, it will not trigger a redraw() (#1592)
  • API: Assigning to vnode.state (as in vnode.state = ...) is no longer supported. Instead, an error is thrown if vnode.state changes upon the invocation of a lifecycle hook.
  • API: m.request will no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies an extract callback. This gives applications more control over handling server responses.
  • hyperscript: when attributes have a null or undefined value, they are treated as if they were absent. #1773 (#2174)
  • API: m.request errors no longer copy response fields to the error, but instead assign the parsed JSON response to error.response and the HTTP status code error.code.
  • hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an attrs field, respectively), the latter takes precedence, except for class attributes that are still added together. #2172 (#2174)
  • cast className using toString (#2309)
  • render: call attrs' hooks last, with express exception of onbeforeupdate to allow attrs to block components from even diffing (#2297)
  • API: m.withAttr removed. (#2317)
  • request: data has now been split to params and body and useBody has been removed in favor of just using body. (#2361)
  • route, request: Interpolated arguments are URL-escaped (and for declared routes, URL-unescaped) automatically. If you want to use a raw route parameter, use a variadic parameter like in /asset/:path.../view. This was previously only available in m.route route definitions, but it's now usable in both that and where paths are accepted. (#2361)
  • route, request: Interpolated arguments are not appended to the query string. This means m.request({url: "/api/user/:id/get", params: {id: user.id}}) would result in a request like GET /api/user/1/get, not one like GET /api/user/1/get?id=1. If you really need it in both places, pass the same value via two separate parameters with the non-query-string parameter renamed, like in m.request({url: "/api/user/:urlID/get", params: {id: user.id, urlID: user.id}}). (#2361)
  • route, request: m.route.set, m.request, and m.jsonp all use the same path template syntax now, and vary only in how they receive their parameters. Furthermore, declared routes in m.route shares the same syntax and semantics, but acts in reverse as if via pattern matching. (#2361)
  • request: options.responseType now defaults to "json" if extract is absent, and deserialize receives the parsed response, not the raw string. If you want the old behavior, use responseType: "text". (#2335)
  • request: set Content-Type: application/json; charset=utf-8 for all XHR methods by default, provided they have a body that's != null (#2361, #2421)
    • This can cause CORS issues when issuing GET with bodies, but you can address them through configuring CORS appropriately.
    • Previously, it was only set for all non-GET methods and only when useBody: true was passed (the default), and it was always set for them. Now it's automatically omitted when no body is present, so the hole is slightly broadened.
  • route: query parameters in hash strings are no longer supported (#2448 @isiahmeadows)
    • It's technically invalid in hashes, so I'd rather push people to keep in line with spec.
  • render: validate all elements are either keyed or unkeyed, and treat null/undefined/booleans as strictly unkeyed (#2452 @isiahmeadows)
    • Gives a nice little perf boost with keyed fragments.
    • Minor, but imperceptible impact (within the margin of error) with unkeyed fragments.
    • Also makes the model a lot more consistent - all values are either keyed or unkeyed.
  • vnodes: normalize boolean children to null/undefined at the vnode level, always stringify non-object children that aren't holes (#2452 @isiahmeadows)
    • Previously, true was equivalent to "true" and false was equivalent to "".
    • Previously, numeric children weren't coerced. Now, they are.
    • Unlikely to break most components, but it could break some users.
    • This increases consistency with how booleans are handled with children, so it should be more intuitive.
  • route: key parameter for routes now only works globally for components (#2458 @isiahmeadows)
    • Previously, it worked for route resolvers, too.
    • This lets you ensure global layouts used in render still render by diff.
  • redraw: mithril/redraw now just exposes the m.redraw callback (#2458 @isiahmeadows)
    • The .schedule, .unschedule, and .render properties of the former redrawService are all removed.
    • If you want to know how to work around it, look at the call to mount in Mithril's source for m.route. That should help you in finding ways around the removed feature. (It doesn't take that much more code.)
  • api: m.version has been removed. If you really need the version for whatever reason, just read the version field of mithril/package.json directly. (#2466 @isiahmeadows)
  • route: m.route.prefix(...) is now m.route.prefix = .... (#2469 @isiahmeadows)
    • This is a fully fledged property, so you can not only write to it, but you can also read from it.
    • This aligns better with user intuition.
  • route: m.route.link function removed in favor of m.route.Link component. (#2469 @isiahmeadows)
    • An optional options object is accepted as an attribute. This was initially targeting the old m.route.link function and was transferred to this. (#1930)
    • The new component handles many more edge cases around user interaction, including accessibility.
    • Link navigation can be disabled and cancelled.
    • Link targets can be trivially changed.

News

  • Mithril now only officially supports IE11, Firefox ESR, and the last two versions of Chrome/FF/Edge/Safari. (#2296)
  • API: Introduction of m.redraw.sync() (#1592)
  • API: Event handlers may also be objects with handleEvent methods (#1949, #2222).
  • API: m.request better error message on JSON parse error - (#2195, @codeclown)
  • API: m.request supports timeout as attr - (#1966)
  • API: m.request supports responseType as attr - (#2193)
  • Mocks: add limited support for the DOMParser API (#2097)
  • API: add support for raw SVG in m.trust() string (#2097)
  • render/core: remove the DOM nodes recycling pool (#2122)
  • render/core: revamp the core diff engine, and introduce a longest-increasing-subsequence-based logic to minimize DOM operations when re-ordering keyed nodes.
  • docs: Emphasize Closure Components for stateful components, use them for all stateful component examples.
  • API: ES module bundles are now available for mithril and mithril/stream (#2194 @porsager).
    • All of the m.* properties from mithril are re-exported as named exports in addition to being attached to m.
    • m() itself from mithril is exported as the default export.
    • mithril/stream's primary export is exported as the default export.
  • fragments: allow same attrs/children overloading logic as hyperscript (#2328)
  • route: Declared routes may check against path names with query strings. (#2361)
  • route: Declared routes in m.route now support - and . as delimiters for path segments. This means you can have a route like "/edit/:file.:ext". (#2361)
    • Previously, this was possible to do in m.route.set, m.request, and m.jsonp, but it was wholly untested for and also undocumented.
  • API: m.buildPathname and m.parsePathname added. (#2361)
  • route: Use m.mount(root, null) to unsubscribe and clean up after a m.route(root, ...) call. (#2453)
  • render: new redraw parameter exposed any time a child event handler is used (#2458 @isiahmeadows)
  • route: m.route.SKIP can be returned from route resolvers to skip to the next route (#2469 @isiahmeadows)
  • API: Full DOM no longer required to execute require("mithril"). You just need to set the necessary globals to something, even if null or undefined, so they can be properly used. (#2469 @isiahmeadows)
    • This enables isomorphic use of m.route.Link and m.route.prefix.
    • This enables isomorphic use of m.request, provided the background: true option is set and that an XMLHttpRequest polyfill is included as necessary.
    • Note that methods requiring DOM operations will still throw errors, such as m.render(...), m.redraw(), and m.route(...).
  • render: Align custom elements to work like normal elements, minus all the HTML-specific magic. (#2221)

Bug fixes

  • API: m.route.set() causes all mount points to be redrawn (#1592)
  • render/attrs: Using style objects in hyperscript calls will now properly diff style properties from one render to another as opposed to re-writing all element style properties every render.
  • render/attrs All vnodes attributes are properly removed when absent or set to null or undefined #1804 #2082 (#1865, #2130)
  • render/core: Render state correctly on select change event #1916 (#1918 @robinchew, #2052)
  • render/core: fix various updateNodes/removeNodes issues when the pool and fragments are involved #1990, #1991, #2003, #2021
  • render/core: fix crashes when the keyed vnodes with the same key had different tag values #2128 @JacksonJN (#2130)
  • render/core: fix cached nodes behavior in some keyed diff scenarios #2132 (#2130)
  • render/events: addEventListener and removeEventListener are always used to manage event subscriptions, preventing external interference.
  • render/events: Event listeners allocate less memory, swap at low cost, and are properly diffed now when rendered via m.mount()/m.redraw().
  • render/events: Object.prototype properties can no longer interfere with event listener calls.
  • render/events: Event handlers, when set to literally undefined (or any non-function), are now correctly removed.
  • render/hooks: fixed an ommission that caused oninit to be called unnecessarily in some cases #1992
  • docs: tweaks: (#2104 @mikeyb, #2205, @cavemansspa, #2250 @isiahmeadows, #2265, @isiahmeadows)
  • render/core: avoid touching Object.prototype.__proto__ setter with key: "__proto__" in certain situations (#2251)
  • render/core: Vnodes stored in the dom node supplied to m.render() are now normalized #2266
  • render/core: CSS vars can now be specified in {style} attributes (#2192 @barneycarroll), (#2311 @porsager), (#2312 @isiahmeadows)
  • request: don't modify params, call extract/serialize/deserialize with correct this value (#2288)
  • render: simplify component removal (#2214)
  • render: remove some redundancy within the component initialization code (#2213)
  • API: mithril loads mithril/index.js, not the bundle, so users of mithril/hyperscript, mithril/render, and similar see the same Mithril instance as those just using mithril itself.
    • https://unpkg.com/mithril is configured to receive the minified bundle, not the development bundle.
    • The raw bundle itself remains accessible at mithril.js, and is not browser-wrapped.
    • Note: this will increase overhead with bundlers like Webpack, Rollup, and Browserify.
  • request: autoredraw support fixed for async/await in Chrome (#2428 @isiahmeadows)
  • render: fix when attrs change with onbeforeupdate returning false, then remaining the same on next redraw (#2447 @isiahmeadows)
  • render: fix internal error when onbeforeupdate returns false and then true with new child tree (#2447 @isiahmeadows)
  • route: arbitrary prefixes are properly supported now, including odd prefixes like ?# and invalid prefixes like #foo#bar (#2448 @isiahmeadows)
  • request: correct IE workaround for response type non-support (#2449 @isiahmeadows)
  • render: correct contenteditable check to also check for contentEditable property name (#2450 @isiahmeadows)
  • docs: clarify valid key usage (#2452 @isiahmeadows)
  • route: don't pollute globals (#2453 @isiahmeadows)
  • request: track xhr replacements correctly (#2455 @isiahmeadows)

v2.0.0

4 years ago

When publishing, the npm upload got interrupted and it didn't publish properly. So I unpublished it. Don't try installing this version - it won't work!

v2.0.0-rc.9

4 years ago

This is a hotfix release for critical issues discovered in v2.0.0-rc.8.

I also included various docs fixes in this release to clear up some confusion.

v2.0.0-rc

Breaking changes

  • API: Component vnode children are not normalized into vnodes on ingestion; normalization only happens if and when they are ingested by the view (#2155 (thanks to @magikstm for related optimization #2064))
  • API: m.redraw() is always asynchronous (#1592)
  • API: m.mount() will only render its own root when called, it will not trigger a redraw() (#1592)
  • API: Assigning to vnode.state (as in vnode.state = ...) is no longer supported. Instead, an error is thrown if vnode.state changes upon the invocation of a lifecycle hook.
  • API: m.request will no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies an extract callback. This gives applications more control over handling server responses.
  • hyperscript: when attributes have a null or undefined value, they are treated as if they were absent. #1773 (#2174)
  • API: m.request errors no longer copy response fields to the error, but instead assign the parsed JSON response to error.response and the HTTP status code error.code.
  • hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an attrs field, respectively), the latter takes precedence, except for class attributes that are still added together. #2172 (#2174)
  • render: Align custom elements to work like normal elements, minus all the HTML-specific magic. (#2221)
  • cast className using toString (#2309)
  • render: call attrs' hooks first, with express exception of onbeforeupdate to allow attrs to block components from even diffing (#2297)
  • API: m.withAttr removed. (#2317)
  • request: data has now been split to params and body and useBody has been removed in favor of just using body. (#2361)
  • route, request: Interpolated arguments are URL-escaped (and for declared routes, URL-unescaped) automatically. If you want to use a raw route parameter, use a variadic parameter like in /asset/:path.../view. This was previously only available in m.route route definitions, but it's now usable in both that and where paths are accepted. (#2361)
  • route, request: Interpolated arguments are not appended to the query string. This means m.request({url: "/api/user/:id/get", params: {id: user.id}}) would result in a request like GET /api/user/1/get, not one like GET /api/user/1/get?id=1. If you really need it in both places, pass the same value via two separate parameters with the non-query-string parameter renamed, like in m.request({url: "/api/user/:urlID/get", params: {id: user.id, urlID: user.id}}). (#2361)
  • route, request: m.route.set, m.request, and m.jsonp all use the same path template syntax now, and vary only in how they receive their parameters. Furthermore, declared routes in m.route shares the same syntax and semantics, but acts in reverse as if via pattern matching. (#2361)
  • request: options.responseType now defaults to "json" if extract is absent, and deserialize receives the parsed response, not the raw string. If you want the old behavior, use responseType: "text". (#2335)
  • request: set Content-Type: application/json; charset=utf-8 for all XHR methods by default, provided they have a body that's != null (#2361, #2421)
    • This can cause CORS issues when issuing GET with bodies, but you can address them through configuring CORS appropriately.
    • Previously, it was only set for all non-GET methods and only when useBody: true was passed (the default), and it was always set for them. Now it's automatically omitted when no body is present, so the hole is slightly broadened.
  • route: query parameters in hash strings are no longer supported (#2448 @isiahmeadows)
    • It's technically invalid in hashes, so I'd rather push people to keep in line with spec.
  • render: validate all elements are either keyed or unkeyed, and treat null/undefined/booleans as strictly unkeyed (#2452 @isiahmeadows)
    • Gives a nice little perf boost with keyed fragments.
    • Minor, but imperceptible impact (within the margin of error) with unkeyed fragments.
    • Also makes the model a lot more consistent - all values are either keyed or unkeyed.
  • vnodes: normalize boolean children to null/undefined at the vnode level, always stringify non-object children that aren't holes (#2452 @isiahmeadows)
    • Previously, true was equivalent to "true" and false was equivalent to "".
    • Previously, numeric children weren't coerced. Now, they are.
    • Unlikely to break most components, but it could break some users.
    • This increases consistency with how booleans are handled with children, so it should be more intuitive.
  • route: key parameter for routes now only works globally for components (#2458 @isiahmeadows)
    • Previously, it worked for route resolvers, too.
    • This lets you ensure global layouts used in render still render by diff.
  • redraw: mithril/redraw now just exposes the m.redraw callback (#2458 @isiahmeadows)
    • The .schedule, .unschedule, and .render properties of the former redrawService are all removed.
    • If you want to know how to work around it, look at the call to mount in Mithril's source for m.route. That should help you in finding ways around the removed feature. (It doesn't take that much more code.)
  • api: m.version has been removed. If you really need the version for whatever reason, just read the version field of mithril/package.json directly. (#2466 @isiahmeadows)
  • route: m.route.prefix(...) is now m.route.prefix = .... (#2469 @isiahmeadows)
    • This is a fully fledged property, so you can not only write to it, but you can also read from it.
    • This aligns better with user intuition.
  • route: m.route.link function removed in favor of m.route.Link component. (#2469 @isiahmeadows)
    • An optional options object is accepted as an attribute. This was initially targeting the old m.route.link function and was transferred to this. (#1930)
    • The new component handles many more edge cases around user interaction, including accessibility.
    • Link navigation can be disabled and cancelled.
    • Link targets can be trivially changed.
  • API: Full DOM no longer required to execute require("mithril"). You just need to set the necessary globals to something, even if null or undefined, so they can be properly used. (#2469 @isiahmeadows)
    • This enables isomorphic use of m.route.Link and m.route.prefix.
    • This enables isomorphic use of m.request, provided the background: true option is set and that an XMLHttpRequest polyfill is included as necessary.
    • Note that methods requiring DOM operations will still throw errors, such as m.render(...), m.redraw(), and m.route(...).

News

  • Mithril now only officially supports IE11, Firefox ESR, and the last two versions of Chrome/FF/Edge/Safari. (#2296)
  • API: Introduction of m.redraw.sync() (#1592)
  • API: Event handlers may also be objects with handleEvent methods (#1949, #2222).
  • API: m.request better error message on JSON parse error - (#2195, @codeclown)
  • API: m.request supports timeout as attr - (#1966)
  • API: m.request supports responseType as attr - (#2193)
  • Mocks: add limited support for the DOMParser API (#2097)
  • API: add support for raw SVG in m.trust() string (#2097)
  • render/core: remove the DOM nodes recycling pool (#2122)
  • render/core: revamp the core diff engine, and introduce a longest-increasing-subsequence-based logic to minimize DOM operations when re-ordering keyed nodes.
  • docs: Emphasize Closure Components for stateful components, use them for all stateful component examples.
  • API: ES module bundles are now available for mithril and mithril/stream (#2194 @porsager).
    • All of the m.* properties from mithril are re-exported as named exports in addition to being attached to m.
    • m() itself from mithril is exported as the default export.
    • mithril/stream's primary export is exported as the default export.
  • fragments: allow same attrs/children overloading logic as hyperscript (#2328)
  • route: Declared routes may check against path names with query strings. (#2361)
  • route: Declared routes in m.route now support - and . as delimiters for path segments. This means you can have a route like "/edit/:file.:ext". (#2361)
    • Previously, this was possible to do in m.route.set, m.request, and m.jsonp, but it was wholly untested for and also undocumented.
  • API: m.buildPathname and m.parsePathname added. (#2361)
  • route: Use m.mount(root, null) to unsubscribe and clean up after a m.route(root, ...) call. (#2453)
  • render: new redraw parameter exposed any time a child event handler is used (#2458 @isiahmeadows)
  • route: m.route.SKIP can be returned from route resolvers to skip to the next route (#2469 @isiahmeadows)

Bug fixes

  • API: m.route.set() causes all mount points to be redrawn (#1592)
  • render/attrs: Using style objects in hyperscript calls will now properly diff style properties from one render to another as opposed to re-writing all element style properties every render.
  • render/attrs All vnodes attributes are properly removed when absent or set to null or undefined #1804 #2082 (#1865, #2130)
  • render/core: Render state correctly on select change event #1916 (#1918 @robinchew, #2052)
  • render/core: fix various updateNodes/removeNodes issues when the pool and fragments are involved #1990, #1991, #2003, #2021
  • render/core: fix crashes when the keyed vnodes with the same key had different tag values #2128 @JacksonJN (#2130)
  • render/core: fix cached nodes behavior in some keyed diff scenarios #2132 (#2130)
  • render/events: addEventListener and removeEventListener are always used to manage event subscriptions, preventing external interference.
  • render/events: Event listeners allocate less memory, swap at low cost, and are properly diffed now when rendered via m.mount()/m.redraw().
  • render/events: Object.prototype properties can no longer interfere with event listener calls.
  • render/events: Event handlers, when set to literally undefined (or any non-function), are now correctly removed.
  • render/hooks: fixed an ommission that caused oninit to be called unnecessarily in some cases #1992
  • docs: tweaks: (#2104 @mikeyb, #2205, @cavemansspa, #2250 @isiahmeadows, #2265, @isiahmeadows)
  • render/core: avoid touching Object.prototype.__proto__ setter with key: "__proto__" in certain situations (#2251)
  • render/core: Vnodes stored in the dom node supplied to m.render() are now normalized #2266
  • render/core: CSS vars can now be specified in {style} attributes (#2192 @barneycarroll), (#2311 @porsager), (#2312 @isiahmeadows)
  • request: don't modify params, call extract/serialize/deserialize with correct this value (#2288)
  • render: simplify component removal (#2214)
  • render: remove some redundancy within the component initialization code (#2213)
  • API: mithril loads mithril/index.js, not the bundle, so users of mithril/hyperscript, mithril/render, and similar see the same Mithril instance as those just using mithril itself.
    • https://unpkg.com/mithril is configured to receive the minified bundle, not the development bundle.
    • The raw bundle itself remains accessible at mithril.js, and is not browser-wrapped.
    • Note: this will increase overhead with bundlers like Webpack, Rollup, and Browserify.
  • request: autoredraw support fixed for async/await in Chrome (#2428 @isiahmeadows)
  • render: fix when attrs change with onbeforeupdate returning false, then remaining the same on next redraw (#2447 @isiahmeadows)
  • render: fix internal error when onbeforeupdate returns false and then true with new child tree (#2447 @isiahmeadows)
  • route: arbitrary prefixes are properly supported now, including odd prefixes like ?# and invalid prefixes like #foo#bar (#2448 @isiahmeadows)
  • request: correct IE workaround for response type non-support (#2449 @isiahmeadows)
  • render: correct contenteditable check to also check for contentEditable property name (#2450 @isiahmeadows)
  • docs: clarify valid key usage (#2452 @isiahmeadows)
  • route: don't pollute globals (#2453 @isiahmeadows)
  • request: track xhr replacements correctly (#2455 @isiahmeadows)