Preact 5

https://github.com/preactjs/preact

  • Correct regression introduced in 5.6.0 where re-rendering components with the same root node could duplicate their DOM. Fixes #257.
  • Enforce this.props and this.context, even when a class improperly inherits from Component (eg: calls super() without forwarding arguments)
  • Fix for all empty vnodes ("", null, etc) rendering a comment - this should only occur when an empty vnode is returned from a component's render().
  • Make event handler "on" prefix case-insensitive

Features

  • When rendering null, a comment node will be inserted instead of an empty TextNode.
  • When using linkState() with components instead of DOM elements, use the first argument passed to the event handler as the default value unless a path is given.

Bug Fixes

  • Fix case where switching from a String to Object style value would attempt to assign numeric CSS properties to the element (#233)
  • Fix bug where using all lowercase event names would skip bypass binding implementation (but still mostly work)
  • Fix and test for double-nulling of refs when changing the type of a component's root DOM element (#243)
  • Fix IE bug caused by assigning to the nodeValue property of a TextNode that has been removed from the DOM.
  • Fix this.base not being unset when unmounting High-Order components (#239)

Features

  • #237 Imporving performance by inlining hook calls (thanks @trashhalo!)
  • Disable rendering on unmount (thanks @Madumo!) [discussion]

Bug Fixes

  • Fix keyed node removal issue noted by @localvoid and originally noticed by @kruczy in #235.
  • Fix for erroneously recycled components

🎉 Preact 5 is here! 🎈

Version 5 represents a fairly major jump forward. It should be backwards-compatible, but major version increment is to signify a few new features that will not be made available in older versions - mainly built-in SVG support, and async rendering.

Take a few seconds and upgrade, you'll be happy you did! 🌈

Tip: If you're using preact-compat, it's best to upgrade that to 2.0.0 at the same time. Since Preact 5+ now includes built-in support for SVG, preact-compat@2 drops the preact-svg dependency, saving you around 1.7kb.


Along with the lovely stable stamp, this release includes some finishing touches:

Bug Fixes

  • Fix case where a ref may be nulled before a component is unmounted (#232, thanks @slmgc!)
  • Ensure remounting component trees invokes mount lifecycle events for deeply nested children (thanks to @kruczy @madumo et al for their help with this!)

New Features

  • Style objects now have a lightning fast pipeline out to the DOM. (#228, thanks @trashhalo!)

    Example:
    <div style={{ foo:'bar '}} /> now diffs against the current style rather than stringifying the object

  • Fixed lifecycle event DOM timing! #65 and #96
  • Fixed swapping issue #230

Features

  • #220 - Add Flow definition (fixes #219) - thanks @bouk!

Bug Fixes

  • #218 - Fix nested JSX text children resulting in multiple TextNodes (thanks @bardt!)

Minor Changes

  • Fix an inconsistency with how defaultProps are applied (developit/preact-compat#47)

    A key in props with a value of undefined should be treated as a missing key, and the value from defaultProps should be used in its place.

  • Switch setImmediate backend from MessageChannel to Promise#then (change diff)

    This is much faster!

    However: This comes with the caveat of being unusable for animation. While this matches the use-case for setImmediate() within Preact (debouncing rendering), it means that componentDidUpdate() and setState() callbacks should not be used as a means of animation. *

    * This is only true when using the built-in debounce mechanism. Overriding to requestAnimationFrame is still a great way to do animations via these hooks.

Bug Fixes

  • Fix an issue where swapping between functional and classful children of a high-order component could trigger an unmount in certain cases

    💁 If you're using preact-router, this fixes a redirect breakage

  • #207 Fix xlinkHref prop for <svg> tags - thanks @aeosynth!

Bugfixes

  • Ignore props.children if children are manually specified (as jsx children, or the third argument to h())
  • Fix and test for the <svg class> bug @zhenkunou found and reported in #202
  • Tiny size optimizations to offset the cost of the above fix :)
  • Fix and (corrected) test for object style attribute serialization (#204) - thanks @katopz
  • 🎨 Add built-in support for inline SVG! (#202)

Bugfixes

  • Fix issue where value and a few other properties could get out of sync with their DOM counterparts.
  • Fix overly optimistic codemod that was breaking child resolution in 5.0.1-beta.14. The codemod is now more intelligent and will only remove pointless initialization to undefined if not done within a conditionally executable block.
  • Fixes 5.0.1-beta.13 having been published without the beta flag.
  • Bugfix: When recycling old trees due to a Component render producing a different root node, avoid accidentally recycling the base of a high-order child component.

Bug Fixes

  • Fix issue where switching HOC child components could trigger unmount lifecycle methods on the parent

Bug Fixes

  • Fix issue where Components rendering null would break functional root check introduced in 5.0.0-beta9 (#182)
  • Fix clearing a previously null/undefined value when using className compat alias (#181)

New Features

  • Allow functions as VNode children (#154)

This is used in libraries that provide animation functionality by re-rendering function children with changing props:

render() {
  return (
    <SomeAnimator start={0} end={155} loop>
      { hue => (
        <span style={{ color: `hsl(${hue}, 100%, 60%)` }}>Rainbow</span>
      ) }
    </SomeAnimator>
  );
}

Bug Fixes

  • Account for High-Order stateful child components wrapped in one or more functional components (#175)
  • Fix disappearing element issue when swapping component root between Element and Text nodes (#176)
  • Verify nesting ownership when attempting to unmount High-Order components

Other

  • Various performance and memory optimizations

New Features

  • Add support for cloneElement(). See React's Docs for more.

Bug Fixes

  • Wrap DOM property assignment in a try{} block, as it can throw.
  • Fix element reordering regression (#174)

Potentially Breaking Changes

  • Switch to exclusively named exports. Fixes compatibility with ES Module bundlers like Rollup (#150).

Bug Fixes

  • Don't invoke shouldComponentUpdate() when updating via forceUpdate() (#158)
  • Fix diff self-correction issue that resulted in an unnecessary element removal and re-append (#159)

Potentially Breaking Changes

  • DOM event handlers are no longer invoked with the source element as their context (this) (#153)
  • Adding properties to context within a tree no longer overwrites, instead it extends/appends (#156)

Bug Fixes

  • Fix for high-order component mount lifecycle (#143)
  • Fix incorrect rendering of 0 values (#149)

Features

  • Add key property to VNodes (#155)

Optimization

Preact 4:

Preact 5: