Skip to content

Version 2.2.0

Compare
Choose a tag to compare
@mbest mbest released this 08 Apr 08:21
· 1071 commits to master since this release

Bindings enhancements

  • The css binding accepts multiple classes in a string and dynamic class names.
  • The text binding can be used in virtual elements: <!--ko text: myValue--><!--/ko-->
  • For the options binding, it will skip destroyed items (unless optionsIncludeDestroyed is passed as truthy), optionsValue can accept a function just like optionsText, and optionsCaption can be an observable.
  • The with binding will bind to the original child DOM elements when its initial value is truthy, and keep a copy of the elements as a template.
  • The if and ifnot bindings will bind to the original child DOM elements when the initial value is truthy for if or falsy for ifnot. Additionally, they will only re-render the content when the truthiness of the value changes.
  • The attr binding handles the name attribute properly in older versions of IE.

Computed observable and binding dependency enhancements

  • Observables (including computed) include a peek function for access within a computed without adding a dependency.
  • observableArray mutation functions no longer cause a dependency within a computed.
  • Writes to writable computeds can now be chained like observables.
  • Computed observables now have an isActive function that indicates that the computed has dependencies (can be triggered again).
  • change (normal manual subscription) and beforeChange callbacks no longer create dependencies.

foreach and template enhancements

  • When a function is used for the template name, it now receives the binding context as the second argument.
  • The foreach functionality now does its best to understand items that were moved and move their content rather than re-render them.
  • beforeMove and afterMove callbacks can now be configured when using foreach functionality.
  • The foreach and template bindings now accept an as option to give $data an alias.
  • The afterRender, beforeRemove, afterAdd, beforeMove, and afterMove callbacks will no longer cause dependencies.

Other binding enhancements

  • The ko object is now available from within bindings, even if ko is not global, such as when used with an AMD loader.
  • Can access the current element in a binding using the $element variable.
  • Can access the current context directly in a binding using the $context variable.