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

ErikSchierboom / knockout-pre-rendered / 96 / 1
95%
master: 95%

Build:
DEFAULT BRANCH: master
Ran 23 Jun 2018 07:55AM UTC
Files 1
Run time 2s
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

23 Jun 2018 07:53AM UTC coverage: 94.318% (+0.7%) from 93.659%
96.1

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)

249 of 264 relevant lines covered (94.32%)

56.74 hits per line

Source Files on job 96.1
  • Tree
  • List 0
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 96
  • Travis Job 96.1
  • 88950c08 on github
  • Prev Job for on master (#91.1)
  • Next Job for on master (#97.1)
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