Releases: knockout/knockout
Version 3.5.3
Version 3.5.2
This release fixes several bugs and adds Trusted Types support:
Fixed bugs:
foreachdoubles last entries under certain circumstances #2594, #2514- Error calling
bindingEvent.subscribebeforeapplyBindings#2584 - Unmatched closing virtual element throws error in production #2582
- Template binding regression: empty string value throws error #2534
- IE11:
activeElementin IFrame fails rendering #2531 - Select
changeevent fires beforevalueis updated in 3.5.1 #2530 beforeRemovecallback index is always 0 #2560- Exception when binding
propertychangeevent in non-IE browser #2548 - Use of reserved word breaking IE <= 8 compatibility #2503
ko.cleanNodedoesn't removeaddEventListenerhandlers #2314checkedbinding crashes withnull/undefinedarray #2309foreachdescendant bindings evaluated on removal #2305- Infinite recursion in circular pure computeds #2154
New features:
TypeScript:
Version 3.5.1
This release fixes a few regression bugs in 3.5.0:
- Empty template with
ifoption throws an error #2446 - IE error from inserting a node before itself #2450
- Problem with initial
valuebinding on<select>when the options are generated via aforeachbinding #2452 - Missing
arrayChangenotifications when using deferred updates #2454 - Template binding removes
<script>template contents #2484
3.5.1 also fixes some issues with and expands 3.5.0's TypeScript definitions.
Version 3.5.0
Knockout 3.5.0 includes a few new bindings and new ways to interact with observables and bindings. The full list is detailed under 3.5.0 Beta, 3.5.0 RC, and 3.5.0 RC2.
The final 3.5.0 release includes fixes for a few regressions in the pre-production releases:
3.5.0 Release Candidate 2
This release includes a number of fixes for regressions in the previous 3.5.0 release candidate. Given the time since the RC, we also decided to include a few small improvements.
- Fix to maintain an element's focus when it's moved by the
foreachbinding. - Fix changes to
stylebinding to correctly appendpx. - Fix regression to
ko.contextForwhen used afterko.applyBindingsToNode. - Revert changes in
ko.utilsto use native array methods. - Remove global
createChildContextWithAsoption and addnoChildContextbinding option. The default behavior forasmatches previous releases. - Fix the interaction of
descendantsCompleteandif/ifnot/withbindings. - Add an option for
if/ifnot/withbindings:completeOn: "render"will have the binding wait to triggerdescendantsCompleteuntil it is rendered. - Throw an error for unbalanced virtual elements.
ko.applyBindingsthrows an error if a non-Node is given as the second parameter.- Support an
optionsobjects as a parameter tocreateChildContext. - Support a custom rate-limit function as the
methodparameter to therateLimitextender. - Support setting custom CSS properties with the
stylebinding. - Optimize how many elements are moved by
foreach. - Update TypeScript declarations.
We decided to keep the more standard return value for ko.utils.arrayFirst, which now returns undefined instead of null when no item matches.
3.5.0 Release Candidate
Changes since 3.5.0 Beta:
- Expand
descendantsCompleteto include bindings other thancomponent, such asif,with, etc. ko.whenwill return a Promise if called without a callback function.- Include TypeScript declarations.
- A few minor bug fixes.
Version 3.5.0 beta
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
asoption with theforeachbinding, Knockout will set the named value for each item in the array but won't create a child context. In other words, when usingas, you will have to use the named value in bindings:text: item.propertyrather thantext: property. This can be controlled by settingko.options.createChildContextWithAs = true. (See #907) -
To improve performance when array changes are from a known, single operation, such as
push, theforeachbinding no longer filters out destroyed items by default. To turn this off and filter out destroyed items, you can setincludeDestroyed: falsein theforeachbinding or setko.options.foreachHidesDestroyed = trueto use the previous behavior by default. (See #2324)
Other enhancements
- You can react to the completion of bindings such as
ifandwithusing the newchildrenCompletebinding or subscribing to thechildrenCompletebinding event.
(See #2310) - You can react to the completion of components, including nested components, by including a
koDescendantsCompletemethod in the component viewmodel or subscribing to thedescendantsCompletebinding event. (See #2319) - Binding strings can include template literals (backticks) and C++ and C-style comments.
- Observable arrays include
sortedandreversedmethods that return a modified copy of the array. This is in contrast tosortandreversethat modify the array itself. - The new
classbinding supports dynamic class strings. This allows you to use thecssandclassbindings together to support both methods of setting CSS classes. - The new
usingbinding, similarly towith, binds its descendant elements in the context of the child viewmodel. Unlikewith, which re-renders its contents when the viewmodel changes,usingwill just trigger each descendant binding to update. - The new
hiddenbinding works oppositely tovisible. - The new
letbinding 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 toko.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
spectateevent whenever their value changes. Unlike the standardchangeevent, 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
getDependenciesmethod that returns an array of the observables that the computed is currently watching. - The
attrbinding supports namespaced attributes such asxlink:hrefinsvgelements. - The
ko.whenfunction allows you to run code once when an observable or condition becomes true. - The
ko.isObservableArrayfunction can be used to check if something is ako.observableArray. - The
stylebinding will usejQueryif present. Even without jQuery, the binding now supports standard style names, such asbackground-color, and automatically appendspxif 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,
Version 3.4.2
This release fixes a number of bugs related to deferred updates and computed observables.
- stop infinite loop from dirty events in circular computeds (#1943)
- only update a computed if dependency has actually changed; not if it was just dirty (#2174)
- only notify subscriptions that exist when a change occurs; don't notify future subscribers (#2163)
- notify dependent computed of change in reverted observable if the computed previously read a different intermediate value (#1835)
- update a pure computed if a dependency has changed and notification is pending (#2197)
Version 3.4.1
Fixed:
Version 3.4.0
New features and bug fixes
- Improves performance of components, templates, computeds, and observables.
- Includes a native version of deferred updates, along with a microtask queue (
ko.tasks). - Calls a
ko.onErrorhandler, if defined, for errors from asynchronous code. ko.options.useOnlyNativeEventscan be set to tell Knockout to use only native (not jQuery) events.- Includes
ko.isPureComputed().
The 3.4.0 RC release notes has the full list of issues and pull requests included in this release. The final release fixes two regression bugs found in the RC:
- #1903 - New
beforeRemovebehavior can break retained items. - #1905 - Endless recursion possible with
ko.computed.
Possible compatibility issues
- Components now use microtasks to perform updates asynchronously instead of
setTimeout. Since microtasks are run before the browser repaints the page, all loaded components will be initialized and displayed in a single repaint. Although this reduces the overall time needed to display components, it could result in a longer delay before anything is displayed. - The new, native deferred updates feature has a slightly different API and is implemented differently than the Deferred Updates plugin. Migrating from the plugin will generally require some code changes (full details to come soon).
ko.observableandko.computedno longer use a closure when defining their methods, such asdisposeandvalueHasMutated. These functions expectthisto be set correctly and so can't be used directly as a callback. Instead you'll need to usebind, such asobs.dispose.bind(obs).