mbest / knockout.punches

A collection of enhanced binding syntaxes using Knockout 3+
http://mbest.github.io/knockout.punches/
238 stars 19 forks source link

Enable filters for the style and css bindings #52

Closed dancras closed 6 years ago

dancras commented 9 years ago

I noticed that filters don't work for the style binding eg:

<div data-bind="style: {width: value | someFilter }"></div>

I haven't tested thoroughly but it seems that using the same configuration approach as the attr binding works. It is possible to achieve this without a PR using:

ko.punches.namespacedBinding.setDefaultBindingPreprocessor('style', ko.punches.textFilter.preprocessor);

I was wondering if there is some reason css and style bindings haven't been included so far?

mbest commented 9 years ago

This is fine. I'll include it in the next version. The reason I didn't include filters for those bindings before is that I didn't know if anyone would want them.

dancras commented 9 years ago

I guess it's a pretty unusual use case. Thanks for the info.