Pre-release

@mbest mbest released this Dec 29, 2017 · 77 commits to master since this release

Assets 4

Knockout 3.5.0 beta release notes

Full list of issues: https://github.com/knockout/knockout/milestone/9?closed=1

Important: This release includes some minor breaking changes to the foreach binding to improve performance and clarify features. These changes can be turned off using global options.

  • When using the as option with the foreach binding, Knockout will set the named value for each item in the array but won't create a child context. In other words, when using as, you will have to use the named value in bindings: text: item.property rather than text: property. This can be controlled by setting ko.options.createChildContextWithAs = true. (See #907)

  • To improve performance when array changes are from a known, single operation, such as push, the foreach binding no longer filters out destroyed items by default. To turn this off and filter out destroyed items, you can set includeDestroyed: false in the foreach binding or set ko.options.foreachHidesDestroyed = true to use the previous behavior by default. (See #2324)

Other enhancements

  • You can react to the completion of bindings such as if and with using the new childrenComplete binding or subscribing to the childrenComplete binding event.
    (See #2310)
  • You can react to the completion of components, including nested components, by including a koDescendantsComplete method in the component viewmodel or subscribing to the descendantsComplete binding event. (See #2319)
  • Binding strings can include template literals (backticks) and C++ and C-style comments.
  • Observable arrays include sorted and reversed methods that return a modified copy of the array. This is in contrast to sort and reverse that modify the array itself.
  • The new class binding supports dynamic class strings. This allows you to use the css and class bindings together to support both methods of setting CSS classes.
  • The new using binding, similarly to with, binds its descendant elements in the context of the child viewmodel. Unlike with, which re-renders its contents when the viewmodel changes, using will just trigger each descendant binding to update.
  • The new hidden binding works oppositely to visible.
  • The new let binding allows you to set values that can be used in all descendant element bindings, regardless of context.
  • Similarly to let, you can set such values at the root context by providing a function as the third parameter to ko.applyBindings. (See #2024)
  • Performance improvement: String templates are no longer parsed each time they are referenced. Instead the parsed nodes are cached and cloned.
  • Observables notify a new spectate event whenever their value changes. Unlike the standard change event, this new event isn't necessarily delayed by rate-limiting or deferred updates. You can subscribe to the event without waking a sleeping pure computed; the computed will notify the event if it is accessed with a new value.
  • Computed observables include a getDependencies method that returns an array of the observables that the computed is currently watching.
  • The attr binding supports namespaced attributes such as xlink:href in svg elements.
  • The ko.when function allows you to run code once when an observable or condition becomes true.
  • The ko.isObservableArray function can be used to check if something is a ko.observableArray.
  • The style binding will use jQuery if present. Even without jQuery, the binding now supports standard style names, such as background-color, and automatically appends px if needed to styles that expect it.
  • Knockout will throw an error if it finds an unmatched closing virtual element (<!--/ko-->).

Fixes

30 or so separate fixes are included in this release,