Be notified of new releases
Create your free GitHub account today to subscribe to this repository for new releases and build software alongside 28 million developers.Sign up
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
- Fix changes to
stylebinding to correctly append
- Fix regression to
ko.contextForwhen used after
- Revert changes in
ko.utilsto use native array methods.
- Remove global
createChildContextWithAsoption and add
noChildContextbinding option. The default behavior for
asmatches previous releases.
- Fix the interaction of
- Add an option for
completeOn: "render"will have the binding wait to trigger
descendantsCompleteuntil 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 to
- Support a custom rate-limit function as the
methodparameter to the
- Support setting custom CSS properties with the
- Optimize how many elements are moved by
- Update TypeScript declarations.
Changes since 3.5.0 Beta:
descendantsCompleteto include bindings other than
component, such as
ko.whenwill return a Promise if called without a callback function.
- Include TypeScript declarations.
- A few minor bug fixes.
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 the
foreachbinding, 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.propertyrather 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
foreachbinding no longer filters out destroyed items by default. To turn this off and filter out destroyed items, you can set
includeDestroyed: falsein the
foreachbinding or set
ko.options.foreachHidesDestroyed = trueto use the previous behavior by default. (See #2324)
- You can react to the completion of bindings such as
withusing the new
childrenCompletebinding or subscribing to the
- You can react to the completion of components, including nested components, by including a
koDescendantsCompletemethod in the component viewmodel or subscribing to the
descendantsCompletebinding event. (See #2319)
- Binding strings can include template literals (backticks) and C++ and C-style comments.
- Observable arrays include
reversedmethods that return a modified copy of the array. This is in contrast to
reversethat modify the array itself.
- The new
classbinding supports dynamic class strings. This allows you to use the
classbindings together to support both methods of setting CSS classes.
- The new
usingbinding, 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,
usingwill just trigger each descendant binding to update.
- The new
hiddenbinding works oppositely to
- 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 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
spectateevent whenever their value changes. Unlike the standard
changeevent, 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.
attrbinding supports namespaced attributes such as
ko.whenfunction allows you to run code once when an observable or condition becomes true.
ko.isObservableArrayfunction can be used to check if something is a
stylebinding will use
jQueryif present. Even without jQuery, the binding now supports standard style names, such as
background-color, and automatically appends
pxif needed to styles that expect it.
- Knockout will throw an error if it finds an unmatched closing virtual element (
30 or so separate fixes are included in this release,
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)
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 (
- 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.
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
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.computedno longer use a closure when defining their methods, such as
valueHasMutated. These functions expect
thisto be set correctly and so can't be used directly as a callback. Instead you'll need to use
bind, such as
Knockout 3.4.0rc release notes
- #1715 - Add ko.onError handler that provides more consistent error/stack information for async operations and event handlers
- #1728 - Include deferred updates functionality in Knockout core
- #1774 - Add
ko.options.useOnlyNativeEvents(default false) that can control if KO uses jQuery (if available) for binding events
- #1839 - Performance Improvement - for named templates that use a
templateor normal element use the element directly as the template to clone
- #1840 - Performance Improvement - Make observables 2-3x faster to instantiate and reduce memory usage by 50%
- #1841 - Performance Improvement - Make computeds 2x faster to instantiate and reduce memory usage by 50%
- #1870 - Add
- #1256 - Better handling when an item is added while a
beforeRemoveanimation is running
- #1380 - observableArray
reversemethods now return the observableArray rather than the underlying array
- #1510 - Do not define a custom element when a component name matches a standard element
- #1591 - Make
checkedbinding work properly with writable computed observables
- #1613 - IE8 issue with calling .apply with an empty second argument
- #1683 - Rearrange code to avoid prototype issue in Opera mobile
- #1709 -
dontLimitMovesoption should be respected when comparing arrays
- #1718 - ko.toJS no longer replaces RegExp objects with plain objects
- #1756 - Use a hasOwnProperty check when registering components
- #1781 - Trim string in default css binding
- #1783 - Skip template elements when binding
- #1788 - Fix
textInputedge case in IE9
- #1790 - Remove version from
bower.jsonand don't update it in build
- #1794 - Exception in an
afterAddcallback should not cause duplicate elements
- #1810 - Don't check for
- #1855 - Fix potential memory leak in
- #1893 -
hasFocusfixes in IE
#1504 - Component configuration can specify a
synchronous option to render already loaded components synchronously.
#1463 - Component child elements are provided to the
createViewModel method, component child elements are exposed on the binding context as
$componentTemplateNodes, and the
template binding can accept an array of DOM nodes directly through the
#1449 - Binding context now contains a
$component property that references the nearest component view model (allows for easily binding to the root of the current component).
#1596 - Create a writable computed within a custom element component when an expression evaluates to an observable (less need to use
#1576 - computed observables (pure or deferred) notify an
awake event with the current value when awakening, pure computeds notify an
asleep event with an
undefined value when going to sleep, and the
getSubscriptionsCount method on an observable can accept an event name argument to return only the count of subscriptions for that event.
#1543 - Sleeping pure computed observables now cache their value.
#1635 - Export
#1427 - Export
#1321 - Ensure that template nodes are created and moved within the correct document to fix cross-window issues in IE.
#1434 - Binding parser skips all colons between the name and value. Support returning malformed bindings (non key-value pairs).
css binding was not clearing a previously added dynamic class when the value bound against changes to null.
#1507 - Memory leak fix for
#1513 - Fix error in
fixUpContinuousNodeArray when using
#1515 - Update
dependentObservable._latestValue when a pureComputed wakes up (affects debug build only)
#1526 - Component's
require option should not try to do an AMD-style
require in a CommonJS scenario.
#1556 - Check that the value passed to
optionsAfterRender is a function before calling
#1597 - CSS binding now works properly with SVG elements
#1606 - Don't bind contents of
#1623 - When using
null selection should be maintained when
option items are updated.
#1634 - Better clean-up of
Knockout 3.2.0 release notes
- 1290 - Components infrastructure and binding. Reusable, extensible components that can dynamically combine a view model and template. Component documentation
- 1385 - Custom elements as a way to consume components (example:
<my-component params="value: price, format: priceFormat"></my-component>). Custom element documentation
- 1359 -
ko.pureComputed- a computed that sleeps when it has no dependencies. Pure computed documentation
- 1160 - Added
textInputbinding for robust handling of real-time updates (key presses, pasting, drag-and-drop, etc.) to a field as an alternative to
valueUpdateoptions. textInput documentation
- 1146 - Make the
valuebinding act like
checkedValuewhen used on same element as
- 1039 - Bower support now includes distributable (built) files (3.1.0 release was also updated to include these files).