Changelog History
Page 1
-
v2.0.4 Changes
August 18, 2019- ๐ Fix double-rendering of trusted content within
contenteditableelements (#2516 @isiahmeadows) - ๐ Fix error on
m.trustupdating (#2516 @isiahmeadows)
- ๐ Fix double-rendering of trusted content within
-
v2.0.3 Changes
July 28, 2019- ๐ Ensure vnodes are removed correctly in the face of
onbeforeremoveresolving 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.
- ๐ Ensure vnodes are removed correctly in the face of
-
v2.0.1 Changes
July 24, 2019This 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
childrenare 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 aredraw()(#1592) - ๐ API: Assigning to
vnode.state(as invnode.state = ...) is no longer supported. Instead, an error is thrown ifvnode.statechanges upon the invocation of a lifecycle hook. - API:
m.requestwill no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies anextractcallback. This gives applications more control over handling server responses. - hyperscript: when attributes have a
nullorundefinedvalue, they are treated as if they were absent. #1773 (#2174) - ๐ API:
m.requesterrors no longer copy response fields to the error, but instead assign the parsed JSON response toerror.responseand the HTTP status codeerror.code. - hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an
attrsfield, respectively), the latter takes precedence, except forclassattributes that are still added together. #2172 (#2174) - cast className using toString (#2309)
- โก๏ธ render: call attrs' hooks last, with express exception of
onbeforeupdateto allow attrs to block components from even diffing (#2297) - ๐ API:
m.withAttrremoved. (#2317) - ๐ request:
datahas now been split toparamsandbodyanduseBodyhas been removed in favor of just usingbody. (#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 inm.routeroute 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 likeGET /api/user/1/get, not one likeGET /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 inm.request({url: "/api/user/:urlID/get", params: {id: user.id, urlID: user.id}}). (#2361) - route, request:
m.route.set,m.request, andm.jsonpall use the same path template syntax now, and vary only in how they receive their parameters. Furthermore, declared routes inm.routeshares the same syntax and semantics, but acts in reverse as if via pattern matching. (#2361) - 0๏ธโฃ request:
options.responseTypenow defaults to"json"ifextractis absent, anddeserializereceives the parsed response, not the raw string. If you want the old behavior, useresponseType: "text". (#2335) - 0๏ธโฃ request: set
Content-Type: application/json; charset=utf-8for all XHR methods by default, provided they have a body that's!= null(#2361, #2421)- This can cause CORS issues when issuing
GETwith bodies, but you can address them through configuring CORS appropriately. - Previously, it was only set for all non-
GETmethods and only whenuseBody: truewas 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.
- This can cause CORS issues when issuing
- ๐ 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/undefinedat the vnode level, always stringify non-object children that aren't holes (#2452 @isiahmeadows)- Previously,
truewas equivalent to"true"andfalsewas 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.
- Previously,
- route:
keyparameter 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
renderstill render by diff.
- redraw:
mithril/redrawnow just exposes them.redrawcallback (#2458 @isiahmeadows)- The
.schedule,.unschedule, and.renderproperties of the formerredrawServiceare all removed. - If you want to know how to work around it, look at the call to
mountin Mithril's source form.route. That should help you in finding ways around the removed feature. (It doesn't take that much more code.)
- The
- ๐ฆ api:
m.versionhas been removed. If you really need the version for whatever reason, just read theversionfield ofmithril/package.jsondirectly. (#2466 @isiahmeadows) - route:
m.route.prefix(...)is nowm.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.linkfunction removed in favor ofm.route.Linkcomponent. (#2469 @isiahmeadows)- An optional
optionsobject is accepted as an attribute. This was initially targeting the oldm.route.linkfunction 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.
- An optional
๐ 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
handleEventmethods (#1949, #2222). - ๐ API:
m.requestbetter error message on JSON parse error - (#2195, @codeclown) - โฑ API:
m.requestsupportstimeoutas attr - (#1966) - ๐ API:
m.requestsupportsresponseTypeas 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
mithrilandmithril/stream(#2194 @porsager).- All of the
m.*properties frommithrilare re-exported as named exports in addition to being attached tom. m()itself frommithrilis exported as the default export.mithril/stream's primary export is exported as the default export.
- All of the
- 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.routenow 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, andm.jsonp, but it was wholly untested for and also undocumented.
- Previously, this was possible to do in
- ๐ API:
m.buildPathnameandm.parsePathnameadded. (#2361) - route: Use
m.mount(root, null)to unsubscribe and clean up after am.route(root, ...)call. (#2453) - render: new
redrawparameter exposed any time a child event handler is used (#2458 @isiahmeadows) - route:
m.route.SKIPcan 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 ifnullorundefined, so they can be properly used. (#2469 @isiahmeadows)- This enables isomorphic use of
m.route.Linkandm.route.prefix. - This enables isomorphic use of
m.request, provided thebackground: trueoption is set and that anXMLHttpRequestpolyfill is included as necessary. - Note that methods requiring DOM operations will still throw errors, such as
m.render(...),m.redraw(), andm.route(...).
- This enables isomorphic use of
- 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
nullorundefined#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
keyhad differenttagvalues #2128 @JacksonJN (#2130) - render/core: fix cached nodes behavior in some keyed diff scenarios #2132 (#2130)
- ๐ render/events:
addEventListenerandremoveEventListenerare 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.prototypeproperties 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
oninitto 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 withkey: " __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/deserializewith correctthisvalue (#2288) - render: simplify component removal (#2214)
- ๐ render: remove some redundancy within the component initialization code (#2213)
- ๐ API:
mithrilloadsmithril/index.js, not the bundle, so users ofmithril/hyperscript,mithril/render, and similar see the same Mithril instance as those just usingmithrilitself.https://unpkg.com/mithrilis 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/awaitin Chrome (#2428 @isiahmeadows) - โก๏ธ render: fix when attrs change with
onbeforeupdatereturning false, then remaining the same on next redraw (#2447 @isiahmeadows) - โก๏ธ render: fix internal error when
onbeforeupdatereturns 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
contenteditablecheck to also check forcontentEditableproperty name (#2450 @isiahmeadows) - ๐ docs: clarify valid key usage (#2452 @isiahmeadows)
- route: don't pollute globals (#2453 @isiahmeadows)
- request: track xhr replacements correctly (#2455 @isiahmeadows)
- API: Component vnode
-
v2.0.0 Changes
July 24, 2019When 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 Changes
July 17, 2019๐ This is a hotfix release for critical issues discovered in v2.0.0-rc.8.
- It did not previously censor magic attributes, causing lifecycle hooks to be double-called. #2471
- I named the
m.route.Linkselector argumentcomponent:when it should've been calledselector:. #2475 (This is the only breaking change.) - ๐ Routing prevention via
ev.preventDefault()was critically broken, and button values and modifier state was incorrectly tested for. #2476
๐ I also included various docs fixes in this release to clear up some confusion.
v2.0.0-rc
๐ฅ Breaking changes
- API: Component vnode
childrenare 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 aredraw()(#1592) - ๐ API: Assigning to
vnode.state(as invnode.state = ...) is no longer supported. Instead, an error is thrown ifvnode.statechanges upon the invocation of a lifecycle hook. - API:
m.requestwill no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies anextractcallback. This gives applications more control over handling server responses. - hyperscript: when attributes have a
nullorundefinedvalue, they are treated as if they were absent. #1773 (#2174) - ๐ API:
m.requesterrors no longer copy response fields to the error, but instead assign the parsed JSON response toerror.responseand the HTTP status codeerror.code. - hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an
attrsfield, respectively), the latter takes precedence, except forclassattributes 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
onbeforeupdateto allow attrs to block components from even diffing (#2297) - ๐ API:
m.withAttrremoved. (#2317) - ๐ request:
datahas now been split toparamsandbodyanduseBodyhas been removed in favor of just usingbody. (#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 inm.routeroute 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 likeGET /api/user/1/get, not one likeGET /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 inm.request({url: "/api/user/:urlID/get", params: {id: user.id, urlID: user.id}}). (#2361) - route, request:
m.route.set,m.request, andm.jsonpall use the same path template syntax now, and vary only in how they receive their parameters. Furthermore, declared routes inm.routeshares the same syntax and semantics, but acts in reverse as if via pattern matching. (#2361) - 0๏ธโฃ request:
options.responseTypenow defaults to"json"ifextractis absent, anddeserializereceives the parsed response, not the raw string. If you want the old behavior, useresponseType: "text". (#2335) - 0๏ธโฃ request: set
Content-Type: application/json; charset=utf-8for all XHR methods by default, provided they have a body that's!= null(#2361, #2421)- This can cause CORS issues when issuing
GETwith bodies, but you can address them through configuring CORS appropriately. - Previously, it was only set for all non-
GETmethods and only whenuseBody: truewas 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.
- This can cause CORS issues when issuing
- ๐ 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/undefinedat the vnode level, always stringify non-object children that aren't holes (#2452 @isiahmeadows)- Previously,
truewas equivalent to"true"andfalsewas 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.
- Previously,
- route:
keyparameter 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
renderstill render by diff.
- redraw:
mithril/redrawnow just exposes them.redrawcallback (#2458 @isiahmeadows)- The
.schedule,.unschedule, and.renderproperties of the formerredrawServiceare all removed. - If you want to know how to work around it, look at the call to
mountin Mithril's source form.route. That should help you in finding ways around the removed feature. (It doesn't take that much more code.)
- The
- ๐ฆ api:
m.versionhas been removed. If you really need the version for whatever reason, just read theversionfield ofmithril/package.jsondirectly. (#2466 @isiahmeadows) - route:
m.route.prefix(...)is nowm.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.linkfunction removed in favor ofm.route.Linkcomponent. (#2469 @isiahmeadows)- An optional
optionsobject is accepted as an attribute. This was initially targeting the oldm.route.linkfunction 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.
- An optional
- API: Full DOM no longer required to execute
require("mithril"). You just need to set the necessary globals to something, even ifnullorundefined, so they can be properly used. (#2469 @isiahmeadows)- This enables isomorphic use of
m.route.Linkandm.route.prefix. - This enables isomorphic use of
m.request, provided thebackground: trueoption is set and that anXMLHttpRequestpolyfill is included as necessary. - Note that methods requiring DOM operations will still throw errors, such as
m.render(...),m.redraw(), andm.route(...).
- This enables isomorphic use of
๐ 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
handleEventmethods (#1949, #2222). - ๐ API:
m.requestbetter error message on JSON parse error - (#2195, @codeclown) - โฑ API:
m.requestsupportstimeoutas attr - (#1966) - ๐ API:
m.requestsupportsresponseTypeas 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
mithrilandmithril/stream(#2194 @porsager).- All of the
m.*properties frommithrilare re-exported as named exports in addition to being attached tom. m()itself frommithrilis exported as the default export.mithril/stream's primary export is exported as the default export.
- All of the
- 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.routenow 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, andm.jsonp, but it was wholly untested for and also undocumented.
- Previously, this was possible to do in
- ๐ API:
m.buildPathnameandm.parsePathnameadded. (#2361) - route: Use
m.mount(root, null)to unsubscribe and clean up after am.route(root, ...)call. (#2453) - render: new
redrawparameter exposed any time a child event handler is used (#2458 @isiahmeadows) - route:
m.route.SKIPcan 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
nullorundefined#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
keyhad differenttagvalues #2128 @JacksonJN (#2130) - render/core: fix cached nodes behavior in some keyed diff scenarios #2132 (#2130)
- ๐ render/events:
addEventListenerandremoveEventListenerare 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.prototypeproperties 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
oninitto 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 withkey: " __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/deserializewith correctthisvalue (#2288) - render: simplify component removal (#2214)
- ๐ render: remove some redundancy within the component initialization code (#2213)
- ๐ API:
mithrilloadsmithril/index.js, not the bundle, so users ofmithril/hyperscript,mithril/render, and similar see the same Mithril instance as those just usingmithrilitself.https://unpkg.com/mithrilis 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/awaitin Chrome (#2428 @isiahmeadows) - โก๏ธ render: fix when attrs change with
onbeforeupdatereturning false, then remaining the same on next redraw (#2447 @isiahmeadows) - โก๏ธ render: fix internal error when
onbeforeupdatereturns 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
contenteditablecheck to also check forcontentEditableproperty 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-rc.8 Changes
July 12, 2019๐ฑ ๐จ๐จ๐จ This is the final release candidate. There will be no more breaking changes added between now and when v2.0.0 stable is released. What you see here is precisely what to expect from v2.0.0 beyond small bug fixes. ๐จ๐จ๐จ
๐ Few new bug fixes, but a few major breaking changes since v2.0.0-rc.7.
require("mithril/redraw")now returns them.redrawfunction directly. There is no longer anyredrawServiceexposed in any way. #2458m.versionno longer exists. In general, rely on feature detection, not version detection. #2466- The
m.route.linkmethod has been replaced with them.route.Linkcomponent, with a capital L. #2469 - The
m.route.prefixmethod has been made a property instead. #2469
And a couple new features:
- You can use
m.route.SKIPto skip a route fromonmatch. #2469 - It's now safe to
require("mithril")in environments that lack a full DOM implementation. You just need a few of the globals defined, even if just tonullorundefined, to ensure proper instantiation. #2469
๐ฅ Breaking changes
- API: Component vnode
childrenare 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 aredraw()(#1592) - ๐ API: Assigning to
vnode.state(as invnode.state = ...) is no longer supported. Instead, an error is thrown ifvnode.statechanges upon the invocation of a lifecycle hook. - API:
m.requestwill no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies anextractcallback. This gives applications more control over handling server responses. - hyperscript: when attributes have a
nullorundefinedvalue, they are treated as if they were absent. #1773 (#2174) - ๐ API:
m.requesterrors no longer copy response fields to the error, but instead assign the parsed JSON response toerror.responseand the HTTP status codeerror.code. - hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an
attrsfield, respectively), the latter takes precedence, except forclassattributes 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
onbeforeupdateto allow attrs to block components from even diffing (#2297) - ๐ API:
m.withAttrremoved. (#2317) - ๐ request:
datahas now been split toparamsandbodyanduseBodyhas been removed in favor of just usingbody. (#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 inm.routeroute 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 likeGET /api/user/1/get, not one likeGET /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 inm.request({url: "/api/user/:urlID/get", params: {id: user.id, urlID: user.id}}). (#2361) - route, request:
m.route.set,m.request, andm.jsonpall use the same path template syntax now, and vary only in how they receive their parameters. Furthermore, declared routes inm.routeshares the same syntax and semantics, but acts in reverse as if via pattern matching. (#2361) - 0๏ธโฃ request:
options.responseTypenow defaults to"json"ifextractis absent, anddeserializereceives the parsed response, not the raw string. If you want the old behavior, useresponseType: "text". (#2335) - 0๏ธโฃ request: set
Content-Type: application/json; charset=utf-8for all XHR methods by default, provided they have a body that's!= null(#2361, #2421)- This can cause CORS issues when issuing
GETwith bodies, but you can address them through configuring CORS appropriately. - Previously, it was only set for all non-
GETmethods and only whenuseBody: truewas 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.
- This can cause CORS issues when issuing
- ๐ 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/undefinedat the vnode level, always stringify non-object children that aren't holes (#2452 @isiahmeadows)- Previously,
truewas equivalent to"true"andfalsewas 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.
- Previously,
- route:
keyparameter 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
renderstill render by diff.
- redraw:
mithril/redrawnow just exposes them.redrawcallback (#2458 @isiahmeadows)- The
.schedule,.unschedule, and.renderproperties of the formerredrawServiceare all removed. - If you want to know how to work around it, look at the call to
mountin Mithril's source form.route. That should help you in finding ways around the removed feature. (It doesn't take that much more code.)
- The
- ๐ฆ api:
m.versionhas been removed. If you really need the version for whatever reason, just read theversionfield ofmithril/package.jsondirectly. (#2466 @isiahmeadows) - route:
m.route.prefix(...)is nowm.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.linkfunction removed in favor ofm.route.Linkcomponent. (#2469 @isiahmeadows)- An optional
optionsobject is accepted as an attribute. This was initially targeting the oldm.route.linkfunction 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.
- An optional
- API: Full DOM no longer required to execute
require("mithril"). You just need to set the necessary globals to something, even ifnullorundefined, so they can be properly used. (#2469 @isiahmeadows)- This enables isomorphic use of
m.route.Linkandm.route.prefix. - This enables isomorphic use of
m.request, provided thebackground: trueoption is set and that anXMLHttpRequestpolyfill is included as necessary. - Note that methods requiring DOM operations will still throw errors, such as
m.render(...),m.redraw(), andm.route(...).
- This enables isomorphic use of
๐ 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
handleEventmethods (#1949, #2222). - ๐ API:
m.requestbetter error message on JSON parse error - (#2195, @codeclown) - โฑ API:
m.requestsupportstimeoutas attr - (#1966) - ๐ API:
m.requestsupportsresponseTypeas 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
mithrilandmithril/stream(#2194 @porsager).- All of the
m.*properties frommithrilare re-exported as named exports in addition to being attached tom. m()itself frommithrilis exported as the default export.mithril/stream's primary export is exported as the default export.
- All of the
- 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.routenow 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, andm.jsonp, but it was wholly untested for and also undocumented.
- Previously, this was possible to do in
- ๐ API:
m.buildPathnameandm.parsePathnameadded. (#2361) - route: Use
m.mount(root, null)to unsubscribe and clean up after am.route(root, ...)call. (#2453) - render: new
redrawparameter exposed any time a child event handler is used (#2458 @isiahmeadows) - route:
m.route.SKIPcan 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
nullorundefined#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
keyhad differenttagvalues #2128 @JacksonJN (#2130) - render/core: fix cached nodes behavior in some keyed diff scenarios #2132 (#2130)
- ๐ render/events:
addEventListenerandremoveEventListenerare 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.prototypeproperties 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
oninitto 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 withkey: " __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/deserializewith correctthisvalue (#2288) - render: simplify component removal (#2214)
- ๐ render: remove some redundancy within the component initialization code (#2213)
- ๐ API:
mithrilloadsmithril/index.js, not the bundle, so users ofmithril/hyperscript,mithril/render, and similar see the same Mithril instance as those just usingmithrilitself.https://unpkg.com/mithrilis 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/awaitin Chrome (#2428 @isiahmeadows) - โก๏ธ render: fix when attrs change with
onbeforeupdatereturning false, then remaining the same on next redraw (#2447 @isiahmeadows) - โก๏ธ render: fix internal error when
onbeforeupdatereturns 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
contenteditablecheck to also check forcontentEditableproperty 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-rc.7 Changes
July 06, 2019v2.0.0-rc.7
โก๏ธ Several new bug fixes, including the dreaded
Uncaught TypeError: Cannot read property 'onbeforeupdate' of undefinedon Chrome,TypeError: vnode.state is undefinedon Firefox, but there are also a few breaking changes since v2.0.0-rc.6:- ๐ Paths no longer accept
#a=b&c=das equivalent to?a=b&c=d. This aligns with the URL spec better, where#is itself illegal in URL fragments. #2448 - ๐ Fragments must either all contain keys or none contain keys. This is not only recommended by the docs, but also enforced by the framework itself. #2452
null/undefinedare no longer valid in keyed fragments. #2452true,false, andundefinedare all normalized tonullat the vnode level. Unlikely to break people, as the past behavior was so counterintuitive and inconsistent people actively avoided using it as it had a knack for creating subtle bugs. #2452
๐ฅ Breaking changes
- API: Component vnode
childrenare 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 aredraw()(#1592) - ๐ API: Assigning to
vnode.state(as invnode.state = ...) is no longer supported. Instead, an error is thrown ifvnode.statechanges upon the invocation of a lifecycle hook. - API:
m.requestwill no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies anextractcallback. This gives applications more control over handling server responses. - hyperscript: when attributes have a
nullorundefinedvalue, they are treated as if they were absent. #1773 (#2174) - ๐ API:
m.requesterrors no longer copy response fields to the error, but instead assign the parsed JSON response toerror.responseand the HTTP status codeerror.code. - hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an
attrsfield, respectively), the latter takes precedence, except forclassattributes 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
onbeforeupdateto allow attrs to block components from even diffing (#2297) - ๐ API:
m.withAttrremoved. (#2317) - ๐ request:
datahas now been split toparamsandbodyanduseBodyhas been removed in favor of just usingbody. (#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 inm.routeroute 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 likeGET /api/user/1/get, not one likeGET /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 inm.request({url: "/api/user/:urlID/get", params: {id: user.id, urlID: user.id}}). (#2361) - route, request:
m.route.set,m.request, andm.jsonpall use the same path template syntax now, and vary only in how they receive their parameters. Furthermore, declared routes inm.routeshares the same syntax and semantics, but acts in reverse as if via pattern matching. (#2361) - 0๏ธโฃ request:
options.responseTypenow defaults to"json"ifextractis absent, anddeserializereceives the parsed response, not the raw string. If you want the old behavior, useresponseType: "text". (#2335) - 0๏ธโฃ request: set
Content-Type: application/json; charset=utf-8for all XHR methods by default, provided they have a body that's!= null(#2361, #2421)- This can cause CORS issues when issuing
GETwith bodies, but you can address them through configuring CORS appropriately. - Previously, it was only set for all non-
GETmethods and only whenuseBody: truewas 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.
- This can cause CORS issues when issuing
- ๐ 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/undefinedat the vnode level, always stringify non-object children that aren't holes (#2452 @isiahmeadows)- Previously,
truewas equivalent to"true"andfalsewas 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.
- Previously,
๐ 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
handleEventmethods (#1949, #2222). - API:
m.route.linkaccepts an optionaloptionsobject (#1930) - ๐ API:
m.requestbetter error message on JSON parse error - (#2195, @codeclown) - โฑ API:
m.requestsupportstimeoutas attr - (#1966) - ๐ API:
m.requestsupportsresponseTypeas 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
mithrilandmithril/stream(#2194 @porsager).- All of the
m.*properties frommithrilare re-exported as named exports in addition to being attached tom. m()itself frommithrilis exported as the default export.mithril/stream's primary export is exported as the default export.
- All of the
- 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.routenow 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, andm.jsonp, but it was wholly untested for and also undocumented.
- Previously, this was possible to do in
- ๐ API:
m.buildPathnameandm.parsePathnameadded. (#2361) - route: Use
m.mount(root, null)to unsubscribe and clean up after am.route(root, ...)call. (#2453) - ๐ version:
m.versionreturns the previous version string for what's innext. (#2453)- If you're using
next, you should hopefully know what you're doing. If you need stability, don't usenext. (This is also why I'm not labelling it as a breaking change.)
- If you're using
๐ 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
nullorundefined#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
keyhad differenttagvalues #2128 @JacksonJN (#2130) - render/core: fix cached nodes behavior in some keyed diff scenarios #2132 (#2130)
- ๐ render/events:
addEventListenerandremoveEventListenerare 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.prototypeproperties 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
oninitto 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 withkey: " __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/deserializewith correctthisvalue (#2288) - render: simplify component removal (#2214)
- ๐ render: remove some redundancy within the component initialization code (#2213)
- ๐ API:
mithrilloadsmithril/index.js, not the bundle, so users ofmithril/hyperscript,mithril/render, and similar see the same Mithril instance as those just usingmithrilitself.https://unpkg.com/mithrilis 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/awaitin Chrome (#2428 @isiahmeadows) - โก๏ธ render: fix when attrs change with
onbeforeupdatereturning false, then remaining the same on next redraw (#2447 @isiahmeadows) - โก๏ธ render: fix internal error when
onbeforeupdatereturns 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
contenteditablecheck to also check forcontentEditableproperty name (#2450 @isiahmeadows) - ๐ docs: clarify valid key usage (#2452 @isiahmeadows)
- route: don't pollute globals (#2453 @isiahmeadows)
- request: track xhr replacements correctly (#2455 @isiahmeadows)
- ๐ Paths no longer accept
-
v2.0.0-rc.6 Changes
May 31, 2019Note: this is a pure bug fix update. It includes #2421, but is otherwise basically the same as v2.0.0-rc.5.
๐ฅ Breaking changes
- API: Component vnode
childrenare 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 aredraw()(#1592) - ๐ API: Assigning to
vnode.state(as invnode.state = ...) is no longer supported. Instead, an error is thrown ifvnode.statechanges upon the invocation of a lifecycle hook. - API:
m.requestwill no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies anextractcallback. This gives applications more control over handling server responses. - hyperscript: when attributes have a
nullorundefinedvalue, they are treated as if they were absent. #1773 (#2174) - ๐ API:
m.requesterrors no longer copy response fields to the error, but instead assign the parsed JSON response toerror.responseand the HTTP status codeerror.code. - hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an
attrsfield, respectively), the latter takes precedence, except forclassattributes 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
onbeforeupdateto allow attrs to block components from even diffing (#2297) - ๐ API:
m.withAttrremoved. (#2317) - ๐ request:
datahas now been split toparamsandbodyanduseBodyhas been removed in favor of just usingbody. (#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 inm.routeroute 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 likeGET /api/user/1/get, not one likeGET /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 inm.request({url: "/api/user/:urlID/get", params: {id: user.id, urlID: user.id}}). (#2361) - route, request:
m.route.set,m.request, andm.jsonpall use the same path template syntax now, and vary only in how they receive their parameters. Furthermore, declared routes inm.routeshares the same syntax and semantics, but acts in reverse as if via pattern matching. (#2361) - 0๏ธโฃ request:
options.responseTypenow defaults to"json"ifextractis absent, anddeserializereceives the parsed response, not the raw string. If you want the old behavior, useresponseType: "text". (#2335) - 0๏ธโฃ request: set
Content-Type: application/json; charset=utf-8for all XHR methods by default, provided they have a body that's!= null(#2361, #2421)- This can cause CORS issues when issuing
GETwith bodies, but you can address them through configuring CORS appropriately. - Previously, it was only set for all non-
GETmethods and only whenuseBody: truewas 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.
- This can cause CORS issues when issuing
๐ 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
handleEventmethods (#1949, #2222). - API:
m.route.linkaccepts an optionaloptionsobject (#1930) - ๐ API:
m.requestbetter error message on JSON parse error - (#2195, @codeclown) - โฑ API:
m.requestsupportstimeoutas attr - (#1966) - ๐ API:
m.requestsupportsresponseTypeas 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
mithrilandmithril/stream(#2194 @porsager).- All of the
m.*properties frommithrilare re-exported as named exports in addition to being attached tom. m()itself frommithrilis exported as the default export.mithril/stream's primary export is exported as the default export.
- All of the
- 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.routenow 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, andm.jsonp, but it was wholly untested for and also undocumented.
- Previously, this was possible to do in
- ๐ API:
m.buildPathnameandm.parsePathnameadded. (#2361)
๐ 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
nullorundefined#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
keyhad differenttagvalues #2128 @JacksonJN (#2130) - render/core: fix cached nodes behavior in some keyed diff scenarios #2132 (#2130)
- ๐ render/events:
addEventListenerandremoveEventListenerare 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.prototypeproperties 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
oninitto 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 withkey: " __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/deserializewith correctthisvalue (#2288) - render: simplify component removal (#2214)
- ๐ render: remove some redundancy within the component initialization code (#2213)
- ๐ API:
mithrilloadsmithril/index.js, not the bundle, so users ofmithril/hyperscript,mithril/render, and similar see the same Mithril instance as those just usingmithrilitself.https://unpkg.com/mithrilis 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.
- API: Component vnode
-
v2.0.0-rc.5 Changes
May 29, 2019PSA: ESM builds have been dropped from v2.0 as of #2366. Please update your scripts accordingly, as only CommonJS is supported until we can figure out a way to enable ES module support in a way that doesn't break everyone. (I've had to help troubleshoot way too many Webpack issues to feel comfortable with side-by-side support.)
๐ If all goes well with this release candidate, it will go stable as you see it now.
๐ฅ Breaking changes
- API: Component vnode
childrenare 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 aredraw()(#1592) - ๐ API: Assigning to
vnode.state(as invnode.state = ...) is no longer supported. Instead, an error is thrown ifvnode.statechanges upon the invocation of a lifecycle hook. - API:
m.requestwill no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies anextractcallback. This gives applications more control over handling server responses. - hyperscript: when attributes have a
nullorundefinedvalue, they are treated as if they were absent. #1773 (#2174) - ๐ API:
m.requesterrors no longer copy response fields to the error, but instead assign the parsed JSON response toerror.responseand the HTTP status codeerror.code. - hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an
attrsfield, respectively), the latter takes precedence, except forclassattributes 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
onbeforeupdateto allow attrs to block components from even diffing (#2297) - ๐ API:
m.withAttrremoved. (#2317) - ๐ request:
datahas now been split toparamsandbodyanduseBodyhas been removed in favor of just usingbody. (#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 inm.routeroute 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 likeGET /api/user/1/get, not one likeGET /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 inm.request({url: "/api/user/:urlID/get", params: {id: user.id, urlID: user.id}}). (#2361) - route, request:
m.route.set,m.request, andm.jsonpall use the same path template syntax now, and vary only in how they receive their parameters. Furthermore, declared routes inm.routeshares the same syntax and semantics, but acts in reverse as if via pattern matching. (#2361) - 0๏ธโฃ request:
options.responseTypenow defaults to"json"ifextractis absent, anddeserializereceives the parsed response, not the raw string. If you want the old behavior, useresponseType: "text". (#2335)
๐ 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
handleEventmethods (#1949, #2222). - API:
m.route.linkaccepts an optionaloptionsobject (#1930) - ๐ API:
m.requestbetter error message on JSON parse error - (#2195, @codeclown) - โฑ API:
m.requestsupportstimeoutas attr - (#1966) - ๐ API:
m.requestsupportsresponseTypeas 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
mithrilandmithril/stream(#2194 @porsager).- All of the
m.*properties frommithrilare re-exported as named exports in addition to being attached tom. m()itself frommithrilis exported as the default export.mithril/stream's primary export is exported as the default export.
- All of the
- 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.routenow 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, andm.jsonp, but it was wholly untested for and also undocumented.
- Previously, this was possible to do in
- ๐ API:
m.buildPathnameandm.parsePathnameadded. (#2361)
๐ 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
nullorundefined#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
keyhad differenttagvalues #2128 @JacksonJN (#2130) - render/core: fix cached nodes behavior in some keyed diff scenarios #2132 (#2130)
- ๐ render/events:
addEventListenerandremoveEventListenerare 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.prototypeproperties 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
oninitto 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 withkey: " __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/deserializewith correctthisvalue (#2288) - render: simplify component removal (#2214)
- ๐ render: remove some redundancy within the component initialization code (#2213)
- ๐ API:
mithrilloadsmithril/index.js, not the bundle, so users ofmithril/hyperscript,mithril/render, and similar see the same Mithril instance as those just usingmithrilitself.https://unpkg.com/mithrilis 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.
- API: Component vnode
-
v2.0.0-rc.4 Changes
February 05, 2019๐ฅ Breaking changes
- API: Component vnode
childrenare 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 aredraw()(#1592) - ๐ API: Assigning to
vnode.state(as invnode.state = ...) is no longer supported. Instead, an error is thrown ifvnode.statechanges upon the invocation of a lifecycle hook. - API:
m.requestwill no longer reject the Promise on server errors (eg. status >= 400) if the caller supplies anextractcallback. This gives applications more control over handling server responses. - hyperscript: when attributes have a
nullorundefinedvalue, they are treated as if they were absent. #1773 (#2174) - ๐ API:
m.requesterrors no longer copy response fields to the error, but instead assign the parsed JSON response toerror.responseand the HTTP status codeerror.code. - hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an
attrsfield, respectively), the latter takes precedence, except forclassattributes that are still added together. #2172 (#2174) - stream: when a stream conditionally returns HALT, dependant stream will also end (#2200)
- ๐ render: remove some redundancy within the component initialization code (#2213)
- render: Align custom elements to work like normal elements, minus all the HTML-specific magic. (#2221)
- render: simplify component removal (#2214)
- cast className using toString (#2309)
- โก๏ธ render: call attrs' hooks first, with express exception of
onbeforeupdateto allow attrs to block components from even diffing (#2297) - ๐ API:
m.withAttrremoved. (#2317)
๐ 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
handleEventmethods (#1949, #2222). - API:
m.route.linkaccepts an optionaloptionsobject (#1930) - ๐ API:
m.requestbetter error message on JSON parse error - (#2195, @codeclown) - โฑ API:
m.requestsupportstimeoutas attr - (#1966) - ๐ API:
m.requestsupportsresponseTypeas 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.
- ๐ stream: Add
stream.liftas a user-friendly alternative tomerge -> maporcombine#1944 - API: ES module bundles are now available for
mithrilandmithril/stream(#2194 @porsager).- All of the
m.*properties frommithrilare re-exported as named exports in addition to being attached tom. m()itself frommithrilis exported as the default export.mithril/stream's primary export is exported as the default export.
- All of the
- fragments: allow same attrs/children overloading logic as hyperscript (#2328)
๐ 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
nullorundefined#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
keyhad differenttagvalues #2128 @JacksonJN (#2130) - render/core: fix cached nodes behavior in some keyed diff scenarios #2132 (#2130)
- ๐ render/events:
addEventListenerandremoveEventListenerare 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.prototypeproperties 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
oninitto 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 withkey: " __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/deserializewith correctthisvalue (#2288)
- API: Component vnode