• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ErikSchierboom / knockout-pre-rendered / 96
95%

Build:
DEFAULT BRANCH: master
Ran 23 Jun 2018 07:55AM UTC
Jobs 1
Files 1
Run time 4s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
96

push

travis-ci

ErikSchierboom
Support plain JS and ko-es5 models (#55)

* POJO-Support: Compel knockout to generate _ko_property_writers for a few more of its bindings, by marking them as two-way.

Some of knockout's built-in bindings (checked, hasFocus, selectedOptions, textInput, and value) are already listed as "two-way bindings" by default. For these, knockout generates an additional binding named "_ko_property_writers" which exposes functions for writing these values to non-observable model properties.

We need to tell knockout to generate property writers for more of its built-in bindings, so that `init` can use these to write to the model.

* POJO-Support:  Added utility method for creating a binding preprocessor that generates custom property writers.

Knockout's _twoWayBindings collection only covers basic `name: value` bindings.
For more complex bindings that receive an object literal (including KO's own "attr"), we need to generate property writers ourselves.

* POJO-Support:  Modified `init` binding, to use property writers for non-observable model properties.

This commit expands on the existing logic of finding and invoking fieldAccessors. But if no fieldAccessor is found, or it is not observable, then look for a suitable property writer instead.

* POJO-Support:  Modified `foreachInit` binding, so it can work with plain arrays, and also subscribe to changes in a knockout-es5 tracked array property.

The trickiest part of this commit is setting up the subscription with change tracking. When the array comes from a knockout-es5 "tracked" model, it is actually being read from an ES5 property getter which reads from an internal observableArray. But we don't have access to that underlying observableArray here, so we can't call `array.subscribe(..., "arrayChange")`.

Instead, we take advantage of Knockout's dependency tracking and set up a `ko.computed` which reads the array from `valueAccessor()`. This sets up a dependency such that the body of our `com... (continued)

76 of 76 new or added lines in 1 file covered. (100.0%)

249 of 264 relevant lines covered (94.32%)

56.74 hits per line

Jobs
ID Job ID Ran Files Coverage
1 96.1 23 Jun 2018 07:55AM UTC 0
94.32
Travis Job 96.1
Source Files on build 96
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #96
  • 88950c08 on github
  • Prev Build on master (#91)
  • Next Build on master (#97)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc